gitlab

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 7 Imported by: 0

README

forge-gitlab

GitLab release provider for forge

Go Reference Pipeline Coverage phpboyscout Go toolkit

Part of the phpboyscout Go toolkit. Full documentation lives on the core module's site: forge.go.phpboyscout.uk


Implements the forge.Provider contract for GitLab releases, using gitlab-org/api/client-go.

It is its own module so a tool that only supports GitLab never compiles GitHub's client, Gitea's, or Bitbucket's. A depfootprint guard asserts that.

Use it

Blank-import to register, then resolve through the registry — your code never names a GitLab type:

import (
    "gitlab.com/phpboyscout/go/forge"

    _ "gitlab.com/phpboyscout/go/forge-gitlab"
)

factory, err := forge.Lookup("gitlab")
provider, err := factory(source, cfg)
go get gitlab.com/phpboyscout/go/forge-gitlab

Configuration

Key Purpose
gitlab.auth.env Name of an environment variable holding the token
gitlab.auth.keychain OS keychain reference, service/account
gitlab.auth.value Literal token (weakest — avoid in committed config)
gitlab.url.api Override the API endpoint
GITLAB_TOKEN Well-known fallback

ReleaseSource.Host selects a self-hosted instance; empty means gitlab.com. A token is optional — public projects resolve unauthenticated.

Security

The PRIVATE-TOKEN credential is attached only to asset downloads on the configured instance, via forge.HostTrusted. Asset URLs come from release metadata that a release author controls, so an unpinned credential is an exfiltration primitive. Host, port and scheme must all match, which also refuses a downgrade to plaintext HTTP.

Documentation

Guides, the provider contract, and how to author your own: forge.go.phpboyscout.uk.

API reference: pkg.go.dev.

License

See LICENSE.

Documentation

Overview

Package gitlab implements the VCS release provider for GitLab repositories, supporting both public and token-authenticated access; the owner may be a slash-separated group path passed through to the GitLab API. Provider construction uses package-owned Settings; GTB config integration lives in SettingsFromConfig.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewReleaseProvider

func NewReleaseProvider(settings Settings) (forge.Provider, error)

NewReleaseProvider builds a GitLab release provider from explicit typed settings. A public repository needs no auth settings; Host selects the instance, empty means gitlab.com, and APIURL can override the derived API endpoint. When auth is absent, the token falls back to GITLAB_TOKEN.

Types

type GitLabReleaseProvider

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

GitLabReleaseProvider implements forge.Provider.

func (*GitLabReleaseProvider) DownloadReleaseAsset

func (p *GitLabReleaseProvider) DownloadReleaseAsset(ctx context.Context, owner, repo string, asset forge.ReleaseAsset) (io.ReadCloser, string, error)

DownloadReleaseAsset is more complex for GitLab.

func (*GitLabReleaseProvider) GetLatestRelease

func (p *GitLabReleaseProvider) GetLatestRelease(ctx context.Context, owner, repo string) (forge.Release, error)

func (*GitLabReleaseProvider) GetReleaseByTag

func (p *GitLabReleaseProvider) GetReleaseByTag(ctx context.Context, owner, repo, tag string) (forge.Release, error)

func (*GitLabReleaseProvider) ListReleases

func (p *GitLabReleaseProvider) ListReleases(ctx context.Context, owner, repo string, limit int) ([]forge.Release, error)

type Settings

type Settings struct {
	ReleaseSource forge.ReleaseSourceConfig
	APIURL        string `json:"api_url" yaml:"api_url"`
	Auth          forge.AuthConfig
}

Settings contains the typed configuration needed to construct a GitLab release provider without binding the provider to GTB config.

Fields are populated by the GTB config adapter via the narrow forge.TokenConfig seam, not decoded with mapstructure. The json/yaml tags are for documentation and serialisation only.

func SettingsFromConfig

func SettingsFromConfig(src forge.ReleaseSourceConfig, cfg forge.TokenConfig) Settings

SettingsFromConfig adapts the gitlab config subtree into typed provider settings. It preserves the existing `url.api` and `auth.*` key layout.

Jump to

Keyboard shortcuts

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