gitlab

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MPL-2.0 Imports: 22 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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.

View Source
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

func CanonicalOrigin(raw string) (string, error)

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 IsStatus

func IsStatus(err error, status int) bool

func IsTaken

func IsTaken(err error) bool

IsTaken reports GitLab's "(key) has already been taken" create refusal.

func TLSConfig

func TLSConfig(pin, caBundlePEM string) (*tls.Config, error)

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

func ValidatePin(pin string) error

ValidatePin checks an SPKI pin's shape: base64(sha256(SubjectPublicKeyInfo)).

func ValidateScope

func ValidateScope(scope string) error

ValidateScope checks a GitLab environment_scope value.

Types

type API

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 (c *Client) DeleteVariable(ctx context.Context, d adapter.Destination, key, scope string) error

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) Token

func (c *Client) Token(ctx context.Context) (TokenInfo, error)

func (*Client) UpdateVariable

func (c *Client) UpdateVariable(ctx context.Context, d adapter.Destination, v Variable) (WriteResult, error)

func (*Client) Version

func (c *Client) Version(ctx context.Context) (string, error)

type ClientConfig

type ClientConfig struct {
	Origin       string
	Credential   string
	AllowedCIDRs []netip.Prefix
	Deadline     time.Duration
	SPKIPin      string
	CABundlePEM  string
}

type DestinationIdentity

type DestinationIdentity struct {
	ID   int64
	Path string
}

DestinationIdentity is the immutable numeric id and the current full path GitLab reports for a project or group.

type Module

type Module struct {
	API API
	Now func() time.Time
}

func (*Module) Plan

func (m *Module) Plan(ctx context.Context, req adapter.PlanRequest) (adapter.Plan, error)

func (*Module) Sync

func (*Module) TestConnection

func (m *Module) TestConnection(ctx context.Context, req adapter.ConnectionRequest) (adapter.Connection, error)

func (*Module) ValidateConfig

func (m *Module) ValidateConfig(cfg adapter.Config) error

type ResponseError

type ResponseError struct {
	Status int
	Taken  bool
}

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 }

Jump to

Keyboard shortcuts

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