Documentation
¶
Overview ¶
Package gitlab adapts the GitLab REST API to gitprovider read and write models.
Index ¶
- Variables
- type Client
- func (c *Client) Capabilities() gitprovider.ProviderCaps
- func (c *Client) GetDiff(ctx context.Context, ref gitprovider.PRRef) (gitprovider.UnifiedDiff, error)
- func (c *Client) GetDiffBetweenRefs(ctx context.Context, ref gitprovider.PRRef, baseSHA, headSHA string) (gitprovider.UnifiedDiff, error)
- func (c *Client) GetFileAtRef(ctx context.Context, ref gitprovider.PRRef, gitRef string, filePath string) ([]byte, error)
- func (c *Client) GetPR(ctx context.Context, ref gitprovider.PRRef) (gitprovider.PR, error)
- func (c *Client) Host() string
- func (c *Client) ListInlineThreads(ctx context.Context, ref gitprovider.PRRef) ([]gitprovider.InlineThread, error)
- func (c *Client) ListIssueComments(ctx context.Context, ref gitprovider.PRRef) ([]gitprovider.IssueComment, error)
- func (c *Client) ListReviews(ctx context.Context, ref gitprovider.PRRef) ([]gitprovider.Review, error)
- func (c *Client) ListTreeAtRef(ctx context.Context, ref gitprovider.PRRef, gitRef string, treePath string) ([]gitprovider.TreeEntry, error)
- func (c *Client) PostInlineComment(ctx context.Context, ref gitprovider.PRRef, comment gitprovider.InlineComment) (gitprovider.CommentID, error)
- func (c *Client) PostIssueComment(ctx context.Context, ref gitprovider.PRRef, body string) (gitprovider.CommentID, error)
- func (c *Client) ReplyToThread(ctx context.Context, ref gitprovider.PRRef, threadID gitprovider.ThreadID, ...) (gitprovider.CommentID, error)
- func (c *Client) ResolveThread(ctx context.Context, ref gitprovider.PRRef, threadID gitprovider.ThreadID) error
- func (c *Client) ReviewAuthority(ctx context.Context, ref gitprovider.PRRef, identity gitprovider.Identity) (gitprovider.ReviewAuthority, error)
- func (c *Client) SubmitReview(ctx context.Context, ref gitprovider.PRRef, request gitprovider.ReviewRequest) (gitprovider.ReviewID, error)
- func (c *Client) WhoAmI(ctx context.Context, creds gitprovider.Credential) (gitprovider.Identity, error)
- type Options
Constants ¶
This section is empty.
Variables ¶
var ErrValidation = errors.New("gitlab: validation error")
ErrValidation identifies non-retryable adapter input or GitLab validation failures.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a GitLab merge-request adapter implementing gitprovider.GitProvider.
func NewFromGitConfig ¶
func NewFromGitConfig(git config.GitConfig, store credentials.Reader, opts Options) (*Client, gitprovider.Credential, error)
NewFromGitConfig builds a GitLab client and credential from config plus a token store.
func (*Client) Capabilities ¶
func (c *Client) Capabilities() gitprovider.ProviderCaps
Capabilities returns GitLab feature support.
func (*Client) GetDiff ¶
func (c *Client) GetDiff(ctx context.Context, ref gitprovider.PRRef) (gitprovider.UnifiedDiff, error)
GetDiff returns the raw unified diff for a merge request. Newer GitLab versions serve it directly; older ones fall back to reconstruction from the per-file diffs listing.
func (*Client) GetDiffBetweenRefs ¶
func (c *Client) GetDiffBetweenRefs(ctx context.Context, ref gitprovider.PRRef, baseSHA, headSHA string) (gitprovider.UnifiedDiff, error)
GetDiffBetweenRefs returns the raw unified diff between two git refs in the merge request's target repository.
func (*Client) GetFileAtRef ¶
func (c *Client) GetFileAtRef(ctx context.Context, ref gitprovider.PRRef, gitRef string, filePath string) ([]byte, error)
GetFileAtRef returns raw file contents at a git ref.
func (*Client) GetPR ¶
func (c *Client) GetPR(ctx context.Context, ref gitprovider.PRRef) (gitprovider.PR, error)
GetPR returns one merge request snapshot.
func (*Client) ListInlineThreads ¶
func (c *Client) ListInlineThreads(ctx context.Context, ref gitprovider.PRRef) ([]gitprovider.InlineThread, error)
ListInlineThreads returns merge-request discussions anchored to the diff.
func (*Client) ListIssueComments ¶
func (c *Client) ListIssueComments(ctx context.Context, ref gitprovider.PRRef) ([]gitprovider.IssueComment, error)
ListIssueComments returns non-system merge-request notes without a diff position, GitLab's equivalent of pull-request issue comments.
func (*Client) ListReviews ¶
func (c *Client) ListReviews(ctx context.Context, ref gitprovider.PRRef) ([]gitprovider.Review, error)
ListReviews maps current merge-request approvals to provider-neutral reviews. GitLab has no first-class review object: approvals are current state (revoking removes them), and review summaries are posted as notes.
func (*Client) ListTreeAtRef ¶
func (c *Client) ListTreeAtRef(ctx context.Context, ref gitprovider.PRRef, gitRef string, treePath string) ([]gitprovider.TreeEntry, error)
ListTreeAtRef returns the git tree entries at a ref and path.
func (*Client) PostInlineComment ¶
func (c *Client) PostInlineComment(ctx context.Context, ref gitprovider.PRRef, comment gitprovider.InlineComment) (gitprovider.CommentID, error)
PostInlineComment starts a new diff discussion on the merge request.
func (*Client) PostIssueComment ¶
func (c *Client) PostIssueComment(ctx context.Context, ref gitprovider.PRRef, body string) (gitprovider.CommentID, error)
PostIssueComment posts a merge-request note.
func (*Client) ReplyToThread ¶
func (c *Client) ReplyToThread(ctx context.Context, ref gitprovider.PRRef, threadID gitprovider.ThreadID, body string) (gitprovider.CommentID, error)
ReplyToThread adds a note to an existing merge-request discussion.
func (*Client) ResolveThread ¶
func (c *Client) ResolveThread(ctx context.Context, ref gitprovider.PRRef, threadID gitprovider.ThreadID) error
ResolveThread marks a merge-request discussion resolved.
func (*Client) ReviewAuthority ¶
func (c *Client) ReviewAuthority(ctx context.Context, ref gitprovider.PRRef, identity gitprovider.Identity) (gitprovider.ReviewAuthority, error)
ReviewAuthority reports whether the resolved posting identity can approve merge requests on the target project. GitLab requires at least Developer access to approve.
func (*Client) SubmitReview ¶
func (c *Client) SubmitReview(ctx context.Context, ref gitprovider.PRRef, request gitprovider.ReviewRequest) (gitprovider.ReviewID, error)
SubmitReview posts the final review verdict. GitLab has no single review submission primitive, so the approval state changes first (approve for approve events, revoke for request-changes events) and the summary body is then posted as a merge-request note. Ordering matters for retries: the summary note carries the idempotency marker, so it must be the last write.
func (*Client) WhoAmI ¶
func (c *Client) WhoAmI(ctx context.Context, creds gitprovider.Credential) (gitprovider.Identity, error)
WhoAmI returns the identity for the supplied credential.