Documentation
¶
Overview ¶
Package gitlab is the GitLab provider: Provider implements scm.Provider on top of the GitLab REST API (gitlab.com/gitlab-org/api/client-go).
Index ¶
- func ConnectivityCheck() error
- type Provider
- func (Provider) ConnectivityCheck() error
- func (Provider) CreateComment(ctx context.Context, repo scm.RepoRef, num int, body string) (scm.Comment, error)
- func (Provider) CredentialsHint() string
- func (Provider) CurrentUser(ctx context.Context) (string, error)
- func (Provider) DetectCI() bool
- func (Provider) Dialect() comment.Dialect
- func (Provider) Enabled() bool
- func (Provider) EventFromCIEnv() (webhook.EventInfo, error)
- func (Provider) GetChangeRequest(ctx context.Context, repo scm.RepoRef, num int) (scm.ChangeRequest, error)
- func (Provider) ListChangedFiles(ctx context.Context, repo scm.RepoRef, num int) ([]string, error)
- func (Provider) ListComments(ctx context.Context, repo scm.RepoRef, num int) ([]scm.Comment, error)
- func (Provider) Name() string
- func (Provider) RepoHosts() []string
- func (Provider) SetStatus(ctx context.Context, repo scm.RepoRef, sha string, state scm.Status, ...) error
- func (Provider) UpdateComment(ctx context.Context, repo scm.RepoRef, num int, id int64, body string) (scm.Comment, error)
- func (Provider) ValidateConfig() error
- func (Provider) WebhookHandler() scm.WebhookHandler
- type WebhookHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectivityCheck ¶
func ConnectivityCheck() error
ConnectivityCheck confirms the token works by resolving its user (GET /user).
Types ¶
type Provider ¶
type Provider struct{}
Provider implements argo-diff's provider primitives on top of the GitLab API. It holds no state: the client is a package var built in init(), which tests swap for an httptest-backed one.
func (Provider) ConnectivityCheck ¶
func (Provider) CreateComment ¶
func (Provider) CredentialsHint ¶
CredentialsHint names the variable that enables this provider.
func (Provider) CurrentUser ¶
CurrentUser returns the username notes are posted as. With the gitlab connectivity check bypassed it returns "", so notes are matched by marker alone, as the GitHub provider does with its bypass.
func (Provider) EventFromCIEnv ¶
EventFromCIEnv is not supported yet; DetectCI() never selects it.
func (Provider) GetChangeRequest ¶
func (Provider) GetChangeRequest(ctx context.Context, repo scm.RepoRef, num int) (scm.ChangeRequest, error)
GetChangeRequest fetches merge request num (its IID) of repo. A field the API did not return is left empty; see scm.ChangeRequest.
func (Provider) ListChangedFiles ¶
ListChangedFiles returns every path merge request num touches, across all pages of its diffs. A renamed file contributes both its old and its new path, so a manifest-generate-paths filter sees either.
func (Provider) ListComments ¶
ListComments returns every user note on merge request num, oldest first, across all pages. System notes ("added 1 commit", ...) are left out.
func (Provider) RepoHosts ¶
RepoHosts is the configured instance's host, plus its relative URL root if it has one (eg: "example.com/gitlab"), for matching ArgoCD application sources.
func (Provider) SetStatus ¶
func (Provider) SetStatus(ctx context.Context, repo scm.RepoRef, sha string, state scm.Status, description string, dryRun bool) error
SetStatus sets the argo-diff commit status on sha. dryRun (dev mode) logs instead of calling the API.
func (Provider) UpdateComment ¶
func (Provider) UpdateComment(ctx context.Context, repo scm.RepoRef, num int, id int64, body string) (scm.Comment, error)
UpdateComment replaces the body of note id on merge request num. GitLab addresses notes through their MR.
func (Provider) ValidateConfig ¶
ValidateConfig builds the API client, reporting why it cannot be built (eg: a malformed GITLAB_BASE_URL or an unreadable CA file). cmd/main.go calls it once at startup, only when gitlab is enabled.
func (Provider) WebhookHandler ¶
func (Provider) WebhookHandler() scm.WebhookHandler
type WebhookHandler ¶
type WebhookHandler struct{}
WebhookHandler is a placeholder until GitLab webhook support lands (issue #160, Phase 4). No route serves GitLab webhooks yet; should one reach it, Verify() rejects the request.
func (WebhookHandler) CheckConfig ¶
func (WebhookHandler) CheckConfig() error
CheckConfig warns that GitLab merge requests can only be processed from event files (-f) or /dev for now. It does not fail, so a server with GITLAB_TOKEN set still starts for GitHub.
func (WebhookHandler) Parse ¶
func (WebhookHandler) Parse(h http.Header, _ []byte) (scm.WebhookEvent, error)