gitlab

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gitlab reads tags, releases, files and directory listings of projects on gitlab.com or a self-managed GitLab host through its REST API, with the same methods the GitHub client offers the digester.

Index

Constants

View Source
const (
	HeaderPrivateToken = "PRIVATE-TOKEN"
	HeaderJobToken     = "JOB-TOKEN"
)

Token header names. A personal, project or group token goes in HeaderPrivateToken, a CI job token in HeaderJobToken.

Variables

View Source
var ErrBadRepo = errors.New("not a gitlab project path")

ErrBadRepo is wrapped by errors for an empty project path.

View Source
var ErrNotPublic = errors.New("the project isn't public")

ErrNotPublic means the project's visibility is private or internal.

Functions

This section is empty.

Types

type Client

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

Client reads tags, releases and files of projects on one GitLab host.

func New

func New(hc *http.Client, o Options) *Client

New returns a client for o.Host that sends requests through hc. The token goes only to that host.

func (*Client) Authenticated

func (c *Client) Authenticated() bool

Authenticated reports whether the client has a token.

func (*Client) File

func (c *Client) File(ctx context.Context, repo, ref, path string) ([]byte, error)

File returns path in repo at ref; an empty ref means the default branch.

func (*Client) Host

func (c *Client) Host() string

Host returns the host the client reads from.

func (*Client) ReleaseBodies

func (c *Client) ReleaseBodies(ctx context.Context, repo string, tags []string) (map[string]github.Release, error)

ReleaseBodies returns the releases of repo for tags, keyed by tag. The release list is read once per client.

func (*Client) Releases

func (c *Client) Releases(ctx context.Context, repo string) ([]github.Release, error)

Releases lists every release of repo with its notes. An upcoming release counts as a draft.

func (*Client) RootFiles

func (c *Client) RootFiles(ctx context.Context, repo string) ([]github.File, error)

RootFiles lists the top directory of repo on its default branch. The tree has no sizes, so each file has size -1.

func (*Client) TagRefs

func (c *Client) TagRefs(ctx context.Context, repo string) ([]version.Ref, error)

TagRefs lists every tag of repo with its commit date.

func (*Client) Tags

func (c *Client) Tags(ctx context.Context, repo string) ([]string, error)

Tags lists every tag name of repo.

func (*Client) Visibility added in v0.13.0

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

Visibility returns nil when the project at repo is public, ErrNotPublic when it is private or internal, and the lookup's error otherwise. A project the client can't see answers 404.

type Options

type Options struct {
	Host        string // gitlab.com or a self-managed host
	Token       string // empty means anonymous requests
	TokenHeader string // [HeaderPrivateToken] (the default) or [HeaderJobToken]
	Scheme      string // https unless a test sets http
}

Options configures New.

Jump to

Keyboard shortcuts

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