Documentation
¶
Overview ¶
Package gitlab implements the GitLab CI/CD variable deployment adapter.
GitLab's variable GET and list endpoints return stored values, so this provider boundary deliberately cannot express any variable read: existence and ownership come from Hikyo's ledger alone, and a POST refused because the key is already taken is the only way an unowned variable is discovered.
Index ¶
- Variables
- func CanonicalOrigin(raw string) (string, error)
- func FullPath(d adapter.Destination) string
- func IsStatus(err error, status int) bool
- func IsTaken(err error) bool
- func TLSConfig(pin, caBundlePEM string) (*tls.Config, error)
- func ValidatePin(pin string) error
- func ValidateScope(scope string) error
- type API
- type Client
- func (c *Client) CreateVariable(ctx context.Context, d adapter.Destination, v Variable) (WriteResult, error)
- func (c *Client) DeleteVariable(ctx context.Context, d adapter.Destination, key, scope string) error
- func (c *Client) Forget()
- func (c *Client) ResolveDestination(ctx context.Context, d adapter.Destination) (DestinationIdentity, error)
- func (c *Client) Token(ctx context.Context) (TokenInfo, error)
- func (c *Client) UpdateVariable(ctx context.Context, d adapter.Destination, v Variable) (WriteResult, error)
- func (c *Client) Version(ctx context.Context) (string, error)
- type ClientConfig
- type DestinationIdentity
- type Module
- func (m *Module) Plan(ctx context.Context, req adapter.PlanRequest) (adapter.Plan, error)
- func (m *Module) Sync(ctx context.Context, req adapter.SyncRequest, journal adapter.Journal) (adapter.SyncResult, error)
- func (m *Module) TestConnection(ctx context.Context, req adapter.ConnectionRequest) (adapter.Connection, error)
- func (m *Module) ValidateConfig(cfg adapter.Config) error
- type ResponseError
- type TokenInfo
- type Variable
- type WriteResult
Constants ¶
This section is empty.
Variables ¶
var ErrPersonalToken = errors.New("gitlab: personal access tokens are refused; use a project or group access token with the api scope and the Maintainer role, or recreate the adapter with allow_personal_token to accept a token that can act as its human owner everywhere they have access")
ErrPersonalToken is the documented refusal for a personal access token.
var ErrSPKIPinMismatch = errors.New("gitlab: server certificate does not match the configured SPKI pin")
ErrSPKIPinMismatch identifies a certificate pin refusal through the redacted transport error chain. It does not replace normal certificate verification.
Functions ¶
func CanonicalOrigin ¶
CanonicalOrigin accepts an HTTPS GitLab base URL, optionally under a relative URL root, and returns it without a trailing slash or /api/v4.
func FullPath ¶
func FullPath(d adapter.Destination) string
FullPath is the configured GitLab path a destination names.
func TLSConfig ¶
TLSConfig builds the adapter egress TLS policy: TLS >= 1.2, normal chain verification against the system roots plus an optional CA bundle, and, when pinned, a SubjectPublicKeyInfo match against the verified chain.
func ValidatePin ¶
ValidatePin checks an SPKI pin's shape: base64(sha256(SubjectPublicKeyInfo)).
func ValidateScope ¶
ValidateScope checks a GitLab environment_scope value.
Types ¶
type API ¶
type API interface {
Version(context.Context) (string, error)
Token(context.Context) (TokenInfo, error)
ResolveDestination(context.Context, adapter.Destination) (DestinationIdentity, error)
CreateVariable(context.Context, adapter.Destination, Variable) (WriteResult, error)
UpdateVariable(context.Context, adapter.Destination, Variable) (WriteResult, error)
DeleteVariable(context.Context, adapter.Destination, string, string) error
}
API is the closed GitLab surface. There is no variable read or list method: both would disclose stored values. The closure test pins this method set.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(cfg ClientConfig) (*Client, error)
func (*Client) CreateVariable ¶
func (c *Client) CreateVariable(ctx context.Context, d adapter.Destination, v Variable) (WriteResult, error)
func (*Client) DeleteVariable ¶
func (*Client) Forget ¶
func (c *Client) Forget()
Forget releases this module lease's private transport and bearer.
func (*Client) ResolveDestination ¶
func (c *Client) ResolveDestination(ctx context.Context, d adapter.Destination) (DestinationIdentity, error)
func (*Client) UpdateVariable ¶
func (c *Client) UpdateVariable(ctx context.Context, d adapter.Destination, v Variable) (WriteResult, error)
type ClientConfig ¶
type DestinationIdentity ¶
DestinationIdentity is the immutable numeric id and the current full path GitLab reports for a project or group.
type Module ¶
func (*Module) Sync ¶
func (m *Module) Sync(ctx context.Context, req adapter.SyncRequest, journal adapter.Journal) (adapter.SyncResult, error)
func (*Module) TestConnection ¶
func (m *Module) TestConnection(ctx context.Context, req adapter.ConnectionRequest) (adapter.Connection, error)
type ResponseError ¶
ResponseError carries the status and whether GitLab reported the key as already taken. It never carries the response body.
func (*ResponseError) Error ¶
func (e *ResponseError) Error() string
type TokenInfo ¶
type TokenInfo struct {
Scopes []string
Active bool
Revoked bool
ExpiresAt time.Time
// Bot is true for project and group access tokens, whose user is a
// GitLab-managed bot. A personal access token belongs to a human user.
Bot bool
}
TokenInfo is value-free metadata about the presented access token.
type Variable ¶
type Variable struct {
Key string
Value string
Scope string
Protected bool
Masked bool
Hidden bool
Raw bool
}
Variable is one write request. Masked and Hidden are only ever set for secret-classified keys; Hidden is honoured on creation only.
type WriteResult ¶
type WriteResult struct{ Status int }