gitlab

package
v0.38.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package gitlab implements the GitLab Provider for the git-platform-sdk.

It builds on top of the official gitlab-org/api/client-go SDK and adds transport-layer cross-cutting behavior (auth, retry, hooks, logging) provided by the parent project's transport package. All Provider methods are split across the per-responsibility files in this package:

  • gitlab.go: constructor + identity (Platform, TestConnection, Capabilities)
  • init.go: provider registration with the global registry
  • repos.go: ListRepos, GetRepo, CreateRepo, DeleteRepo, UpdateRepo, ForkRepo
  • crs.go: Change requests (MRs): Create/Get/List/Close/Merge/Reopen/Update/Comments/Commits
  • webhooks.go: webhook CRUD + signature validation + event parsing
  • branches.go: ListBranches, CreateBranch, DeleteBranch
  • diffs.go: GetCRDiff, GetCRFiles, CreateNote/DeleteNote, CreateDiscussion, CreateReview
  • commits.go: GetCommit, ListCommits, CompareCommits, CreateCommitStatus
  • files.go: GetFileContent, CreateFile, UpdateFile, DeleteFile
  • releases.go: ListTags, ListReleases, CreateRelease, GetArchive
  • labels.go: repository label CRUD (LabelManager)
  • types.go: internal GitLab-API types and conversion helpers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New builds a GitLab Provider from the given config.

Types

type Provider

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

Provider is the GitLab implementation of provider.Provider.

func (*Provider) Capabilities added in v0.38.0

func (p *Provider) Capabilities() provider.CapabilitySet

Capabilities implements provider.Provider. GitLab implements the optional LabelManager interface (see labels.go).

func (*Provider) CloseCR

func (p *Provider) CloseCR(ctx context.Context, owner, repo string, number int) (*provider.ChangeRequest, error)

CloseCR implements provider.ChangeRequestManager.

func (*Provider) CompareCommits

func (p *Provider) CompareCommits(ctx context.Context, owner, repo, base, head string) (*provider.CompareResult, error)

CompareCommits implements provider.CommitManager.

func (*Provider) CreateBranch

func (p *Provider) CreateBranch(ctx context.Context, owner, repo, branch, ref string) (*provider.PlatformBranch, error)

CreateBranch implements provider.BranchManager.

func (*Provider) CreateCR

CreateCR implements provider.ChangeRequestManager.

func (*Provider) CreateCommitStatus

func (p *Provider) CreateCommitStatus(ctx context.Context, owner, repo, sha string, opts provider.CommitStatusOptions) error

CreateCommitStatus implements provider.CommitManager.

func (*Provider) CreateDiscussion

func (p *Provider) CreateDiscussion(ctx context.Context, owner, repo string, number int, opts provider.DiscussionOptions) (string, error)

CreateDiscussion implements provider.DiffManager.

func (*Provider) CreateFile

func (p *Provider) CreateFile(ctx context.Context, owner, repo string, opts provider.FileOptions) (*provider.FileResult, error)

CreateFile implements provider.FileManager.

func (*Provider) CreateLabel added in v0.38.0

func (p *Provider) CreateLabel(ctx context.Context, owner, repo string, opts provider.CreateLabelOptions) (*provider.Label, error)

CreateLabel implements provider.LabelManager. GitLab requires colors with a leading '#'.

func (*Provider) CreateNote

func (p *Provider) CreateNote(ctx context.Context, owner, repo string, number int, body string) (string, error)

CreateNote implements provider.DiffManager.

func (*Provider) CreateRelease

func (p *Provider) CreateRelease(ctx context.Context, owner, repo string, opts provider.CreateReleaseOptions) (*provider.ReleaseInfo, error)

CreateRelease implements provider.ReleaseManager.

func (*Provider) CreateRepo

func (p *Provider) CreateRepo(ctx context.Context, owner string, opts provider.CreateRepoOptions) (*provider.PlatformRepo, error)

CreateRepo implements provider.RepoManager.

func (*Provider) CreateReview

func (p *Provider) CreateReview(ctx context.Context, owner, repo string, number int, opts provider.CreateReviewOptions) (*provider.ReviewResult, error)

CreateReview implements provider.DiffManager.

GitLab has no native "review" object. We approximate one by:

  1. Posting the summary body as a Note (if non-empty).
  2. Posting each inline comment as a Discussion.
  3. Setting a commit status with the verdict (if CommitID is set).

The returned ID is a synthetic identifier; the Comments slice reports the per-comment discussion IDs and any errors.

func (*Provider) CreateWebhook

CreateWebhook implements provider.WebhookManager.

func (*Provider) DeleteBranch

func (p *Provider) DeleteBranch(ctx context.Context, owner, repo, branch string) error

DeleteBranch implements provider.BranchManager.

func (*Provider) DeleteFile

func (p *Provider) DeleteFile(ctx context.Context, owner, repo string, opts provider.FileDeleteOptions) (*provider.FileResult, error)

DeleteFile implements provider.FileManager.

func (*Provider) DeleteLabel added in v0.38.0

func (p *Provider) DeleteLabel(ctx context.Context, owner, repo, name string) error

DeleteLabel implements provider.LabelManager.

func (*Provider) DeleteNote

func (p *Provider) DeleteNote(ctx context.Context, owner, repo string, number int, noteID string) error

DeleteNote implements provider.DiffManager.

func (*Provider) DeleteRepo

func (p *Provider) DeleteRepo(ctx context.Context, owner, repo string) error

DeleteRepo implements provider.RepoManager.

func (*Provider) DeleteWebhook

func (p *Provider) DeleteWebhook(ctx context.Context, owner, repo string, webhookID int64) error

DeleteWebhook implements provider.WebhookManager.

func (*Provider) ForkRepo

func (p *Provider) ForkRepo(ctx context.Context, owner, repo string, opts provider.ForkRepoOptions) (*provider.PlatformRepo, error)

ForkRepo implements provider.RepoManager.

func (*Provider) GetArchive

func (p *Provider) GetArchive(ctx context.Context, owner, repo, ref, format string) ([]byte, error)

GetArchive implements provider.ReleaseManager.

func (*Provider) GetCR

func (p *Provider) GetCR(ctx context.Context, owner, repo string, number int) (*provider.ChangeRequest, error)

GetCR implements provider.ChangeRequestManager.

func (*Provider) GetCRDiff

func (p *Provider) GetCRDiff(ctx context.Context, owner, repo string, number int) (*provider.MergeDiff, error)

GetCRDiff implements provider.DiffManager.

func (*Provider) GetCRFiles

func (p *Provider) GetCRFiles(ctx context.Context, owner, repo string, number int) ([]*provider.ChangedFile, error)

GetCRFiles implements provider.DiffManager.

func (*Provider) GetCommit

func (p *Provider) GetCommit(ctx context.Context, owner, repo, sha string) (*provider.CommitInfo, error)

GetCommit implements provider.CommitManager.

func (*Provider) GetFileContent

func (p *Provider) GetFileContent(ctx context.Context, owner, repo, path, ref string) (string, error)

GetFileContent implements provider.FileManager.

func (*Provider) GetRepo

func (p *Provider) GetRepo(ctx context.Context, owner, repo string) (*provider.PlatformRepo, error)

GetRepo implements provider.RepoManager.

func (*Provider) ListBranches

func (p *Provider) ListBranches(ctx context.Context, owner, repo string) ([]*provider.PlatformBranch, error)

ListBranches implements provider.BranchManager.

func (*Provider) ListCRComments

func (p *Provider) ListCRComments(ctx context.Context, owner, repo string, number int) ([]*provider.CRComment, error)

ListCRComments implements provider.ChangeRequestManager.

func (*Provider) ListCRCommits

func (p *Provider) ListCRCommits(ctx context.Context, owner, repo string, number int) ([]*provider.CRCommit, error)

ListCRCommits implements provider.ChangeRequestManager.

func (*Provider) ListCRs

ListCRs implements provider.ChangeRequestManager.

func (*Provider) ListCommits

func (p *Provider) ListCommits(ctx context.Context, owner, repo string, opts provider.ListCommitsOptions) ([]*provider.CommitInfo, error)

ListCommits implements provider.CommitManager.

func (*Provider) ListLabels added in v0.38.0

func (p *Provider) ListLabels(ctx context.Context, owner, repo string, opts provider.ListLabelsOptions) ([]*provider.Label, error)

ListLabels implements provider.LabelManager.

func (*Provider) ListReleases

func (p *Provider) ListReleases(ctx context.Context, owner, repo string) ([]*provider.ReleaseInfo, error)

ListReleases implements provider.ReleaseManager.

func (*Provider) ListRepos

ListRepos implements provider.RepoManager.

func (*Provider) ListTags

func (p *Provider) ListTags(ctx context.Context, owner, repo string) ([]*provider.TagInfo, error)

ListTags implements provider.ReleaseManager.

func (*Provider) ListWebhooks

func (p *Provider) ListWebhooks(ctx context.Context, owner, repo string) ([]*provider.PlatformWebhook, error)

ListWebhooks implements provider.WebhookManager.

func (*Provider) MergeCR

func (p *Provider) MergeCR(ctx context.Context, owner, repo string, number int, opts provider.MergeCROptions) (*provider.ChangeRequest, error)

MergeCR implements provider.ChangeRequestManager.

func (*Provider) ParseWebhookEvent

func (p *Provider) ParseWebhookEvent(r *http.Request, secret string) (*provider.NormalizedEvent, error)

ParseWebhookEvent implements provider.WebhookManager.

func (*Provider) Platform

func (p *Provider) Platform() provider.Platform

Platform implements provider.Provider.

func (*Provider) ReopenCR

func (p *Provider) ReopenCR(ctx context.Context, owner, repo string, number int) (*provider.ChangeRequest, error)

ReopenCR implements provider.ChangeRequestManager.

func (*Provider) TestConnection

func (p *Provider) TestConnection(ctx context.Context) (*provider.TestConnectionResult, error)

TestConnection implements provider.Provider.

func (*Provider) UpdateCR

func (p *Provider) UpdateCR(ctx context.Context, owner, repo string, number int, opts provider.UpdateCROptions) (*provider.ChangeRequest, error)

UpdateCR implements provider.ChangeRequestManager.

func (*Provider) UpdateCRLabels

func (p *Provider) UpdateCRLabels(ctx context.Context, owner, repo string, number int, labels []string) error

UpdateCRLabels implements provider.ChangeRequestManager.

func (*Provider) UpdateFile

func (p *Provider) UpdateFile(ctx context.Context, owner, repo string, opts provider.FileOptions) (*provider.FileResult, error)

UpdateFile implements provider.FileManager.

func (*Provider) UpdateLabel added in v0.38.0

func (p *Provider) UpdateLabel(ctx context.Context, owner, repo, name string, opts provider.UpdateLabelOptions) (*provider.Label, error)

UpdateLabel implements provider.LabelManager. GitLab addresses labels by numeric ID, so the label is resolved by name first.

func (*Provider) UpdateRepo

func (p *Provider) UpdateRepo(ctx context.Context, owner, repo string, opts provider.UpdateRepoOptions) (*provider.PlatformRepo, error)

UpdateRepo implements provider.RepoManager.

func (*Provider) ValidateWebhookSignature

func (p *Provider) ValidateWebhookSignature(r *http.Request, secret string) error

ValidateWebhookSignature implements provider.WebhookManager. GitLab uses a static-token comparison against the X-Gitlab-Token header.

Jump to

Keyboard shortcuts

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