gitlab

package
v14.53.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package gitlab provides an HTTP client for the GitLab internal API. It is the replacement for the client and gitlabnet packages and is being introduced incrementally as part of the consolidation described in https://gitlab.com/gitlab-org/gitlab-shell/-/issues/834.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseJSON

func ParseJSON(resp *http.Response, dst any) error

ParseJSON decodes a successful (< 400) HTTP response body into dst, or returns a *client.APIError describing the failure. The error semantics deliberately match those of the old client package so that sub-clients migrated to this package do not need to change their error handling:

  • 4xx/5xx with a JSON {"message":"…"} body → *client.APIError{Msg: message}
  • 4xx/5xx with no decodable message → *client.APIError{Msg: "Internal API error (N)"}
  • 2xx with non-JSON body → errors.New("parsing failed")

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an HTTP client for the GitLab internal API.

func New

func New(cfg *Config) (*Client, error)

New creates a new Client from the given Config.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string) (*http.Response, error)

Get makes a GET request to the given internal API path.

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, body any) (*http.Response, error)

Post makes a POST request to the given internal API path with a JSON body.

func (*Client) WithHost added in v14.50.0

func (c *Client) WithHost(host string) *Client

WithHost returns a shallow copy of the client that sends requests to the specified host instead of the default one. The returned client shares the same HTTP transport, TLS settings, and authentication credentials. This is used for Cells routing where the Topology Service directs requests to a specific cell.

type Config

type Config struct {
	// GitlabURL is the base URL of the GitLab instance.
	GitlabURL string
	// RelativeURLRoot is an optional relative URL root prefix (for Unix socket URLs).
	RelativeURLRoot string
	// User is the HTTP basic auth username.
	User string
	// Password is the HTTP basic auth password.
	Password string
	// Secret is the HS256 JWT signing secret. Must not be empty.
	Secret string
	// CaFile is the path to a custom CA certificate file.
	CaFile string
	// CaPath is the path to a directory of custom CA certificate files.
	CaPath string
	// ReadTimeoutSeconds is the HTTP read timeout. Defaults to 300s when zero.
	ReadTimeoutSeconds uint64
}

Config holds the configuration for the GitLab internal API client.

type HealthcheckClient added in v14.52.0

type HealthcheckClient struct {
	// contains filtered or unexported fields
}

HealthcheckClient wraps the gitlab Client for healthcheck requests.

func NewHealthcheckClient added in v14.52.0

func NewHealthcheckClient(client *Client) *HealthcheckClient

NewHealthcheckClient creates a new healthcheck client from the gitlab Client.

func (*HealthcheckClient) Check added in v14.52.0

Check makes a GET request to the healthcheck endpoint and returns the response.

type HealthcheckResponse added in v14.52.0

type HealthcheckResponse struct {
	APIVersion     string `json:"api_version"`
	GitlabVersion  string `json:"gitlab_version"`
	GitlabRevision string `json:"gitlab_rev"`
	Redis          bool   `json:"redis"`
}

HealthcheckResponse contains healthcheck endpoint response data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL