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 ¶
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 (*Client) WithHost ¶ added in v14.50.0
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
func (hc *HealthcheckClient) Check(ctx context.Context) (*HealthcheckResponse, error)
Check makes a GET request to the healthcheck endpoint and returns the response.