Documentation
¶
Index ¶
- type Client
- func (c *Client) CreateVariable(ctx context.Context, projectID string, r CreateRequest) (*Variable, error)
- func (c *Client) DeleteVariable(ctx context.Context, projectID, key, envScope string) error
- func (c *Client) Do(ctx context.Context, req *http.Request) (*http.Response, error)
- func (c *Client) ListVariables(ctx context.Context, projectID string, opts ListOptions) ([]Variable, error)
- func (c *Client) UpdateVariable(ctx context.Context, projectID string, r CreateRequest) (*Variable, error)
- type ClientConfig
- type CreateRequest
- type ListOptions
- type Variable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a rate-limited, retry-aware HTTP client for the GitLab API.
func NewClient ¶
func NewClient(cfg ClientConfig) *Client
NewClient creates a new Client with the given configuration. Default values are applied for zero-value fields.
func (*Client) CreateVariable ¶
func (c *Client) CreateVariable(ctx context.Context, projectID string, r CreateRequest) (*Variable, error)
CreateVariable creates a new CI/CD variable for the given project.
func (*Client) DeleteVariable ¶
DeleteVariable removes a CI/CD variable from the given project. envScope is optional; pass "" to omit the filter.
func (*Client) Do ¶
Do executes an HTTP request with rate limiting, retry, and backoff. The PRIVATE-TOKEN header is injected automatically. 401 responses are returned immediately without retry. 429 responses are retried after honoring the Retry-After header. Network errors are retried up to RetryMax times with exponential backoff.
func (*Client) ListVariables ¶
func (c *Client) ListVariables(ctx context.Context, projectID string, opts ListOptions) ([]Variable, error)
ListVariables returns all variables for the given project, following pagination.
func (*Client) UpdateVariable ¶
func (c *Client) UpdateVariable(ctx context.Context, projectID string, r CreateRequest) (*Variable, error)
UpdateVariable updates an existing CI/CD variable identified by r.Key and r.EnvironmentScope.
type ClientConfig ¶
type ClientConfig struct {
BaseURL string
Token string
RequestsPerSecond float64
Burst int
RetryMax int
RetryInitialBackoff time.Duration
HTTPClient *http.Client
}
ClientConfig holds configuration for the GitLab HTTP client.
type CreateRequest ¶
type CreateRequest struct {
Key string `json:"key"`
Value string `json:"value"`
VariableType string `json:"variable_type"`
EnvironmentScope string `json:"environment_scope"`
Protected bool `json:"protected"`
Masked bool `json:"masked"`
Raw bool `json:"raw"`
}
CreateRequest is the payload for creating or updating a variable.
type ListOptions ¶
ListOptions controls pagination and filtering for ListVariables.
type Variable ¶
type Variable struct {
Key string `json:"key"`
Value string `json:"value"`
VariableType string `json:"variable_type"`
EnvironmentScope string `json:"environment_scope"`
Protected bool `json:"protected"`
Masked bool `json:"masked"`
Raw bool `json:"raw"`
}
Variable represents a GitLab CI/CD project variable.
func FilterByScope ¶
FilterByScope filters variables by environment scope on the client side. GitLab API does not reliably filter by environment_scope on the LIST endpoint (see https://gitlab.com/gitlab-org/gitlab/-/issues/343169), so we do it ourselves.
Filtering rules:
- empty scope: return all variables unfiltered
- scope == "*": return only variables with EnvironmentScope == "*"
- specific scope: return variables with EnvironmentScope == scope OR EnvironmentScope == "*"