gitlab

package
v1.19.2 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorParamEmpty liberr.CodeError = iota + libart.MinArtifactGitlab
	ErrorURLParse
	ErrorClientInit
	ErrorGitlabList
	ErrorGitlabGetRelease
	ErrorGitlabNotFound
	ErrorGitlabRequestNew
	ErrorGitlabRequestRun
	ErrorGitlabResponse
	ErrorGitlabIOCopy
	ErrorDestinationStat
	ErrorDestinationSize
)
View Source
const (
	GitlabAPIBase    = "/api" // GitLab API base path
	GitlabAPIVersion = "/v4"  // GitLab API version path
)

Variables

This section is empty.

Functions

func GetGitlabOptions added in v1.19.0

func GetGitlabOptions(baseUrl string, httpcli *http.Client) (opt []gitlab.ClientOptionFunc, err error)

GetGitlabOptions constructs GitLab client options with proper API path configuration. It ensures the base URL includes the GitLab API base path (/api) and version (/v4).

Parameters:

Returns client options that can be passed to gitlab.NewClient or similar constructors.

Example:

opts, err := GetGitlabOptions("https://gitlab.example.com", nil)
// Results in baseUrl: "https://gitlab.example.com/api/v4"

func NewGitlabAuthSource added in v1.19.0

func NewGitlabAuthSource(ctx context.Context, htc *http.Client, uri string, pid int, tkn oauth2.TokenSource) (cli libart.Client, err error)

NewGitlabAuthSource creates a GitLab artifact client using an OAuth2 token source. This method supports automatic token refresh and is recommended for OAuth2 authentication.

Parameters:

  • ctx: Request context
  • htc: Optional HTTP client for custom transport/timeout
  • uri: GitLab instance URL (e.g., "https://gitlab.com")
  • pid: Project ID (numeric, found in project settings)
  • tkn: OAuth2 token source (handles token refresh automatically)

Returns a client implementing the artifact.Client interface.

func NewGitlabAuthUser deprecated

func NewGitlabAuthUser(ctx context.Context, htc *http.Client, usr, pwd, uri string, pid int) (cli libart.Client, err error)

NewGitlabAuthUser creates a GitLab artifact client using basic authentication (username/password).

Deprecated: Basic authentication is being phased out by GitLab. Use NewGitlabPrivateToken instead.

Parameters:

  • ctx: Request context
  • htc: Optional HTTP client
  • usr: GitLab username
  • pwd: GitLab password
  • uri: GitLab instance URL
  • pid: Project ID (numeric)

func NewGitlabOAuth deprecated

func NewGitlabOAuth(ctx context.Context, htc *http.Client, tkn, uri string, pid int) (cli libart.Client, err error)

NewGitlabOAuth creates a GitLab artifact client using OAuth token authentication.

Deprecated: Use NewGitlabAuthSource for OAuth2 token source authentication.

Parameters:

  • ctx: Request context
  • htc: Optional HTTP client
  • tkn: OAuth token
  • uri: GitLab instance URL
  • pid: Project ID (numeric)

func NewGitlabPrivateToken

func NewGitlabPrivateToken(ctx context.Context, httpcli *http.Client, token, baseUrl string, projectId int) (cli libart.Client, err error)

NewGitlabPrivateToken creates a GitLab artifact client using a private token (recommended). This is the most common and recommended authentication method for GitLab.

Parameters:

  • ctx: Request context for API calls
  • httpcli: Optional HTTP client for custom transport/timeout configuration
  • token: GitLab private token (create at User Settings > Access Tokens)
  • baseUrl: GitLab instance URL (e.g., "https://gitlab.com" or "https://gitlab.example.com")
  • projectId: Project ID (numeric, found in project settings under "Project ID")

Returns a client implementing the artifact.Client interface for:

  • Listing releases with version filtering
  • Retrieving artifact download URLs
  • Streaming artifact downloads

Example:

ctx := context.Background()
client, err := NewGitlabPrivateToken(ctx, nil, "glpat-xxxxx", "https://gitlab.com", 12345)
if err != nil {
    log.Fatal(err)
}
versions, _ := client.ListReleases()

Types

This section is empty.

Jump to

Keyboard shortcuts

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