Documentation
¶
Index ¶
- type Client
- func (g *Client) CreateComment(logger logging.SimpleLogging, repo models.Repo, pullNum int, comment string, ...) error
- func (g *Client) DiscardReviews(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest) error
- func (g *Client) GetCloneURL(logger logging.SimpleLogging, _ models.VCSHostType, repo string) (string, error)
- func (g *Client) GetFileContent(logger logging.SimpleLogging, repo models.Repo, branch string, fileName string) (bool, []byte, error)
- func (g *Client) GetMergeRequest(logger logging.SimpleLogging, repoFullName string, pullNum int) (*gitlab.MergeRequest, error)
- func (g *Client) GetModifiedFiles(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest) ([]string, error)
- func (g *Client) GetPullLabels(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest) ([]string, error)
- func (g *Client) GetTeamNamesForUser(logger logging.SimpleLogging, _ models.Repo, user models.User) ([]string, error)
- func (g *Client) GetVersion(logger logging.SimpleLogging) (*version.Version, error)
- func (g *Client) HidePrevCommandComments(logger logging.SimpleLogging, repo models.Repo, pullNum int, command string, ...) error
- func (g *Client) MarkdownPullLink(pull models.PullRequest) (string, error)
- func (g *Client) MergePull(logger logging.SimpleLogging, pull models.PullRequest, ...) error
- func (g *Client) PullIsApproved(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest) (approvalStatus models.ApprovalStatus, err error)
- func (g *Client) PullIsMergeable(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest, ...) (models.MergeableStatus, error)
- func (g *Client) ReactToComment(logger logging.SimpleLogging, repo models.Repo, pullNum int, commentID int64, ...) error
- func (g *Client) SupportsCommonMark() bool
- func (g *Client) SupportsDetailedMergeStatus(logger logging.SimpleLogging) (bool, error)
- func (g *Client) SupportsSingleFileDownload(_ models.Repo) bool
- func (g *Client) UpdateStatus(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest, ...) error
- func (g *Client) WaitForSuccessPipeline(logger logging.SimpleLogging, ctx context.Context, pull models.PullRequest)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Client *gitlab.Client
// Version is set to the server version.
Version *version.Version
// All GitLab groups configured in allowlists and policies
ConfiguredGroups []string
// PollingInterval is the time between successive polls, where applicable.
PollingInterval time.Duration
// PollingInterval is the total duration for which to poll, where applicable.
PollingTimeout time.Duration
// StatusRetryEnabled enables enhanced retry logic for pipeline status updates.
StatusRetryEnabled bool
}
func New ¶
func New(hostname string, token string, configuredGroups []string, logger logging.SimpleLogging) (*Client, error)
NewClient returns a valid GitLab client.
func (*Client) CreateComment ¶
func (g *Client) CreateComment(logger logging.SimpleLogging, repo models.Repo, pullNum int, comment string, _ string) error
CreateComment creates a comment on the merge request.
func (*Client) DiscardReviews ¶
func (g *Client) DiscardReviews(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest) error
DiscardReviews discards all reviews on a pull request This is only available with a bot token and otherwise will return 401 unauthorized https://docs.gitlab.com/api/merge_request_approvals/#reset-approvals-of-a-merge-request
func (*Client) GetCloneURL ¶
func (g *Client) GetCloneURL(logger logging.SimpleLogging, _ models.VCSHostType, repo string) (string, error)
func (*Client) GetFileContent ¶
func (g *Client) GetFileContent(logger logging.SimpleLogging, repo models.Repo, branch string, fileName string) (bool, []byte, error)
GetFileContent a repository file content from VCS (which support fetch a single file from repository) The first return value indicates whether the repo contains a file or not if BaseRepo had a file, its content will placed on the second return value
func (*Client) GetMergeRequest ¶
func (g *Client) GetMergeRequest(logger logging.SimpleLogging, repoFullName string, pullNum int) (*gitlab.MergeRequest, error)
func (*Client) GetModifiedFiles ¶
func (g *Client) GetModifiedFiles(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest) ([]string, error)
GetModifiedFiles returns the names of files that were modified in the merge request relative to the repo root, e.g. parent/child/file.txt.
func (*Client) GetPullLabels ¶
func (g *Client) GetPullLabels(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest) ([]string, error)
func (*Client) GetTeamNamesForUser ¶
func (g *Client) GetTeamNamesForUser(logger logging.SimpleLogging, _ models.Repo, user models.User) ([]string, error)
GetTeamNamesForUser returns the names of the GitLab groups that the user belongs to. The user membership is checked in each group from configuredTeams, groups that the Atlantis user doesn't have access to are silently ignored.
func (*Client) GetVersion ¶
GetVersion returns the version of the Gitlab server this client is using.
func (*Client) HidePrevCommandComments ¶
func (*Client) MarkdownPullLink ¶
func (g *Client) MarkdownPullLink(pull models.PullRequest) (string, error)
MarkdownPullLink specifies the string used in a pull request comment to reference another pull request.
func (*Client) MergePull ¶
func (g *Client) MergePull(logger logging.SimpleLogging, pull models.PullRequest, pullOptions models.PullRequestOptions) error
MergePull merges the merge request.
func (*Client) PullIsApproved ¶
func (g *Client) PullIsApproved(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest) (approvalStatus models.ApprovalStatus, err error)
PullIsApproved returns true if the merge request was approved.
func (*Client) PullIsMergeable ¶
func (g *Client) PullIsMergeable(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest, vcsstatusname string, _ []string) (models.MergeableStatus, error)
PullIsMergeable returns true if the merge request can be merged. In GitLab, there isn't a single field that tells us if the pull request is mergeable so for now we check the merge_status and approvals_before_merge fields. In order to check if the repo required these, we'd need to make another API call to get the repo settings. It's also possible that GitLab implements their own "mergeable" field in their API in the future. See: - https://gitlab.com/gitlab-org/gitlab-ee/issues/3169 - https://gitlab.com/gitlab-org/gitlab-ce/issues/42344
func (*Client) ReactToComment ¶
func (g *Client) ReactToComment(logger logging.SimpleLogging, repo models.Repo, pullNum int, commentID int64, reaction string) error
ReactToComment adds a reaction to a comment.
func (*Client) SupportsCommonMark ¶
SupportsCommonMark returns true if the version of Gitlab this client is using supports the CommonMark markdown format.
func (*Client) SupportsDetailedMergeStatus ¶
func (g *Client) SupportsDetailedMergeStatus(logger logging.SimpleLogging) (bool, error)
func (*Client) SupportsSingleFileDownload ¶
func (*Client) UpdateStatus ¶
func (g *Client) UpdateStatus(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest, state models.CommitStatus, src string, description string, url string) error
UpdateStatus updates the build status of a commit.
func (*Client) WaitForSuccessPipeline ¶
func (g *Client) WaitForSuccessPipeline(logger logging.SimpleLogging, ctx context.Context, pull models.PullRequest)