Documentation
¶
Index ¶
- Constants
- type GitlabClient
- func (c *GitlabClient) AddMergeRequestDiscussionReply(ctx context.Context, mrIID int, project, discussionID, comment string) (vcs.MRNote, error)
- func (c *GitlabClient) CloneMergeRequest(ctx context.Context, project string, mr vcs.MR, dest string) (vcs.GitRepo, error)
- func (c *GitlabClient) CreateMergeRequestComment(ctx context.Context, mrIID int, projectID, comment string) error
- func (c *GitlabClient) CreateMergeRequestCommentWithID(ctx context.Context, mrIID int, projectID, comment string) (int64, error)
- func (c *GitlabClient) CreateMergeRequestDiscussion(ctx context.Context, mrIID int, project, comment string) (vcs.MRDiscussionNotes, error)
- func (c *GitlabClient) GetAuthenticatedAccountName(ctx context.Context) (string, error)
- func (g *GitlabClient) GetCommitJobStatuses(ctx context.Context, project, commitSHA string) ([]vcs.CommitJobStatus, error)
- func (c *GitlabClient) GetCommitStatuses(ctx context.Context, projectID, commitSHA string) []*gogitlab.CommitStatus
- func (g *GitlabClient) GetMergeRequest(ctx context.Context, mrIID int, project string) (vcs.DetailedMR, error)
- func (g *GitlabClient) GetMergeRequestApprovals(ctx context.Context, mrIID int, project string) (vcs.MRApproved, error)
- func (g *GitlabClient) GetMergeRequestModifiedFiles(ctx context.Context, mrIID int, projectID string) ([]string, error)
- func (c *GitlabClient) GetOldRunUrls(ctx context.Context, mrIID int, project string, rootNoteID int, ...) (string, error)
- func (g *GitlabClient) GetPipelinesForCommit(ctx context.Context, project, commitSHA string) ([]vcs.ProjectPipeline, error)
- func (g *GitlabClient) GetProjectSettings(ctx context.Context, project string) (vcs.ProjectSettings, error)
- func (g *GitlabClient) GetRepoFile(ctx context.Context, project, file, ref string) ([]byte, error)
- func (c *GitlabClient) ListMergeRequestNotes(ctx context.Context, mrIID int, projectID string) []*gogitlab.Note
- func (g *GitlabClient) ListRepoDirectories(ctx context.Context, project, dir, ref string) ([]string, error)
- func (c *GitlabClient) MergeMR(ctx context.Context, mrIID int, project string) error
- func (c *GitlabClient) MergeMRAtSHA(ctx context.Context, mrIID int, project, expectedSHA string) error
- func (c *GitlabClient) ResolveMergeRequestDiscussion(ctx context.Context, projectWithNamespace string, mrIID int, ...) error
- func (c *GitlabClient) ResolveMergeRequestDiscussionReply(ctx context.Context, mrIID int, project, discussionID string, resolved bool) error
- func (c *GitlabClient) ResolveMergeRequestDiscussions(ctx context.Context, project string, mrIID int, workspace string, ...) error
- func (c *GitlabClient) SetCommitStatus(ctx context.Context, projectWithNS string, commitSHA string, ...) (vcs.CommitStatus, error)
- func (c *GitlabClient) SetWorkspaceStatus(ctx context.Context, ws vcs.WorkspaceStatus) error
- func (c *GitlabClient) SupportsAggregateAutoMerge() bool
- func (c *GitlabClient) UpdateMergeRequestComment(ctx context.Context, mrIID int, noteID int64, projectID, comment string) error
- func (c *GitlabClient) UpdateMergeRequestDiscussionNote(ctx context.Context, mrIID, noteID int, project, discussionID, comment string) (vcs.MRNote, error)
- type GitlabCommitJobStatus
- type GitlabCommitStatus
- type GitlabCommitStatusOptions
- func (gO *GitlabCommitStatusOptions) GetContext() string
- func (gO *GitlabCommitStatusOptions) GetDescription() string
- func (gO *GitlabCommitStatusOptions) GetName() string
- func (gO *GitlabCommitStatusOptions) GetPipelineID() int
- func (gO *GitlabCommitStatusOptions) GetState() string
- func (gO *GitlabCommitStatusOptions) GetTargetURL() string
- type GitlabMR
- func (gm *GitlabMR) GetAuthor() vcs.MRAuthor
- func (gm *GitlabMR) GetInternalID() int
- func (gm *GitlabMR) GetSourceBranch() string
- func (gm *GitlabMR) GetState() string
- func (gm *GitlabMR) GetTargetBranch() string
- func (gm *GitlabMR) GetTitle() string
- func (gm *GitlabMR) GetWebURL() string
- func (gm *GitlabMR) HasConflicts() bool
- func (gm *GitlabMR) IsDraft() bool
- type GitlabMRApproval
- type GitlabMRAuthor
- type GitlabMRDiscussion
- type GitlabMRNote
- type GitlabMergeCommentEvent
- func (gE *GitlabMergeCommentEvent) GetAttributes() vcs.MRAttributes
- func (gE *GitlabMergeCommentEvent) GetAuthor() vcs.MRAuthor
- func (gE *GitlabMergeCommentEvent) GetDiscussionID() string
- func (gE *GitlabMergeCommentEvent) GetEventSequence() int64
- func (gE *GitlabMergeCommentEvent) GetInternalID() int
- func (gE *GitlabMergeCommentEvent) GetLastCommit() vcs.Commit
- func (gE *GitlabMergeCommentEvent) GetMR() vcs.MR
- func (gE *GitlabMergeCommentEvent) GetNote() string
- func (gE *GitlabMergeCommentEvent) GetPathWithNamespace() string
- func (gE *GitlabMergeCommentEvent) GetProject() vcs.Project
- func (gE *GitlabMergeCommentEvent) GetSHA() string
- func (gE *GitlabMergeCommentEvent) GetSourceBranch() string
- func (gE *GitlabMergeCommentEvent) GetTargetBranch() string
- func (gE *GitlabMergeCommentEvent) GetType() string
- func (gE *GitlabMergeCommentEvent) GetUsername() string
- type GitlabPipeline
- type GitlabProjectSettings
- type RunStatusUpdater
Constants ¶
const DefaultMaxRetries = 3
const GITLAB_CLONE_DEPTH_ENV = "TFBUDDY_GITLAB_CLONE_DEPTH"
const MR_COMMENT_FORMAT = `
### Terraform Cloud
%s
`
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GitlabClient ¶
type GitlabClient struct {
// contains filtered or unexported fields
}
func NewGitlabClient ¶
func NewGitlabClient(cfg config.Config) *GitlabClient
func (*GitlabClient) AddMergeRequestDiscussionReply ¶
func (c *GitlabClient) AddMergeRequestDiscussionReply(ctx context.Context, mrIID int, project, discussionID, comment string) (vcs.MRNote, error)
AddMergeRequestDiscussionReply creates a comment on the merge request.
func (*GitlabClient) CloneMergeRequest ¶
func (c *GitlabClient) CloneMergeRequest(ctx context.Context, project string, mr vcs.MR, dest string) (vcs.GitRepo, error)
CloneMergeRequest performs a git clone of the target Gitlab project & merge request branch to the `dest` path.
func (*GitlabClient) CreateMergeRequestComment ¶
func (c *GitlabClient) CreateMergeRequestComment(ctx context.Context, mrIID int, projectID, comment string) error
CreateMergeRequestComment creates a comment on the merge request.
func (*GitlabClient) CreateMergeRequestCommentWithID ¶ added in v0.7.1
func (c *GitlabClient) CreateMergeRequestCommentWithID( ctx context.Context, mrIID int, projectID, comment string, ) (int64, error)
CreateMergeRequestCommentWithID creates a comment and returns its note ID.
func (*GitlabClient) CreateMergeRequestDiscussion ¶
func (c *GitlabClient) CreateMergeRequestDiscussion(ctx context.Context, mrIID int, project, comment string) (vcs.MRDiscussionNotes, error)
func (*GitlabClient) GetAuthenticatedAccountName ¶ added in v0.7.1
func (c *GitlabClient) GetAuthenticatedAccountName(ctx context.Context) (string, error)
func (*GitlabClient) GetCommitJobStatuses ¶ added in v0.6.0
func (g *GitlabClient) GetCommitJobStatuses(ctx context.Context, project, commitSHA string) ([]vcs.CommitJobStatus, error)
GetCommitJobStatuses returns the latest status per job name for a commit, covering both the project's CI jobs and TFBuddy's own TFC/* external statuses. It differs from GetCommitStatuses, which returns only the external stage.
func (*GitlabClient) GetCommitStatuses ¶
func (c *GitlabClient) GetCommitStatuses(ctx context.Context, projectID, commitSHA string) []*gogitlab.CommitStatus
func (*GitlabClient) GetMergeRequest ¶
func (g *GitlabClient) GetMergeRequest(ctx context.Context, mrIID int, project string) (vcs.DetailedMR, error)
func (*GitlabClient) GetMergeRequestApprovals ¶
func (g *GitlabClient) GetMergeRequestApprovals(ctx context.Context, mrIID int, project string) (vcs.MRApproved, error)
func (*GitlabClient) GetMergeRequestModifiedFiles ¶
func (g *GitlabClient) GetMergeRequestModifiedFiles(ctx context.Context, mrIID int, projectID string) ([]string, error)
GetMergeRequestModifiedFiles returns the names of files that were modified in the merge request relative to the repo root, e.g. parent/child/file.txt.
func (*GitlabClient) GetOldRunUrls ¶ added in v0.2.0
func (c *GitlabClient) GetOldRunUrls(ctx context.Context, mrIID int, project string, rootNoteID int, workspace string, action string) (string, error)
GetOldRunUrls crawls MR discussion threads authored by the bot, collects previous TFC run URLs into a collapsible block, and (when TFBUDDY_DELETE_OLD_COMMENTS is set) deletes entire discussion threads that belong to the same workspace+action combination. Threads for other workspaces or actions are left untouched.
func (*GitlabClient) GetPipelinesForCommit ¶
func (g *GitlabClient) GetPipelinesForCommit(ctx context.Context, project, commitSHA string) ([]vcs.ProjectPipeline, error)
func (*GitlabClient) GetProjectSettings ¶ added in v0.6.0
func (g *GitlabClient) GetProjectSettings(ctx context.Context, project string) (vcs.ProjectSettings, error)
func (*GitlabClient) GetRepoFile ¶
GetRepoFile retrieves a single file from a Gitlab repository using the RepositoryFiles API
func (*GitlabClient) ListMergeRequestNotes ¶ added in v0.8.2
func (c *GitlabClient) ListMergeRequestNotes(ctx context.Context, mrIID int, projectID string) []*gogitlab.Note
ListMergeRequestNotes returns every note on a merge request, across pages. Errors are logged and yield an empty list: callers use this to avoid duplicate comments, and a lookup failure should not stop the comment.
func (*GitlabClient) ListRepoDirectories ¶ added in v0.8.3
func (g *GitlabClient) ListRepoDirectories(ctx context.Context, project, dir, ref string) ([]string, error)
ListRepoDirectories returns every directory below dir at ref, recursively, relative to the repo root. A dir that does not exist at ref yields nothing.
func (*GitlabClient) MergeMRAtSHA ¶ added in v0.7.0
func (*GitlabClient) ResolveMergeRequestDiscussion ¶
func (*GitlabClient) ResolveMergeRequestDiscussionReply ¶
func (c *GitlabClient) ResolveMergeRequestDiscussionReply(ctx context.Context, mrIID int, project, discussionID string, resolved bool) error
ResolveMergeRequestDiscussionReply marks a discussion thread as resolved / unresolved.
func (*GitlabClient) ResolveMergeRequestDiscussions ¶ added in v0.7.0
func (*GitlabClient) SetCommitStatus ¶
func (c *GitlabClient) SetCommitStatus(ctx context.Context, projectWithNS string, commitSHA string, status vcs.CommitStatusOptions) (vcs.CommitStatus, error)
func (*GitlabClient) SetWorkspaceStatus ¶ added in v0.8.0
func (c *GitlabClient) SetWorkspaceStatus(ctx context.Context, ws vcs.WorkspaceStatus) error
SetWorkspaceStatus publishes one TFC/<action>/<workspace> commit status. This is the only place in the codebase that builds one.
How long it may take is the caller's to decide, via the context deadline. The asynchronous run-event path passes no deadline and keeps the full eventual-consistency window, because a GitLab pipeline can take seconds to become visible and a status posted too early lands on an unrelated external pipeline. Synchronous webhook callers set a short deadline instead, since overrunning their JetStream AckWait causes a redelivery.
func (*GitlabClient) SupportsAggregateAutoMerge ¶ added in v0.7.0
func (c *GitlabClient) SupportsAggregateAutoMerge() bool
func (*GitlabClient) UpdateMergeRequestComment ¶ added in v0.7.1
func (c *GitlabClient) UpdateMergeRequestComment( ctx context.Context, mrIID int, noteID int64, projectID, comment string, ) error
UpdateMergeRequestComment replaces an existing merge request comment.
func (*GitlabClient) UpdateMergeRequestDiscussionNote ¶
type GitlabCommitJobStatus ¶ added in v0.6.0
type GitlabCommitJobStatus struct {
*gogitlab.CommitStatus
}
func (*GitlabCommitJobStatus) GetAllowFailure ¶ added in v0.6.0
func (gS *GitlabCommitJobStatus) GetAllowFailure() bool
func (*GitlabCommitJobStatus) GetName ¶ added in v0.6.0
func (gS *GitlabCommitJobStatus) GetName() string
func (*GitlabCommitJobStatus) GetPipelineID ¶ added in v0.6.0
func (gS *GitlabCommitJobStatus) GetPipelineID() int
func (*GitlabCommitJobStatus) GetStatus ¶ added in v0.6.0
func (gS *GitlabCommitJobStatus) GetStatus() string
type GitlabCommitStatus ¶
type GitlabCommitStatus struct {
*gogitlab.CommitStatus
}
func (*GitlabCommitStatus) Info ¶
func (gS *GitlabCommitStatus) Info() string
type GitlabCommitStatusOptions ¶
type GitlabCommitStatusOptions struct {
*gogitlab.SetCommitStatusOptions
}
func (*GitlabCommitStatusOptions) GetContext ¶
func (gO *GitlabCommitStatusOptions) GetContext() string
func (*GitlabCommitStatusOptions) GetDescription ¶
func (gO *GitlabCommitStatusOptions) GetDescription() string
func (*GitlabCommitStatusOptions) GetName ¶
func (gO *GitlabCommitStatusOptions) GetName() string
func (*GitlabCommitStatusOptions) GetPipelineID ¶
func (gO *GitlabCommitStatusOptions) GetPipelineID() int
func (*GitlabCommitStatusOptions) GetState ¶
func (gO *GitlabCommitStatusOptions) GetState() string
func (*GitlabCommitStatusOptions) GetTargetURL ¶
func (gO *GitlabCommitStatusOptions) GetTargetURL() string
type GitlabMR ¶
type GitlabMR struct {
*gogitlab.MergeRequest
}
func (*GitlabMR) GetInternalID ¶
func (*GitlabMR) GetSourceBranch ¶
func (*GitlabMR) GetTargetBranch ¶
func (*GitlabMR) HasConflicts ¶
type GitlabMRApproval ¶
type GitlabMRApproval struct {
*gogitlab.MergeRequestApprovals
}
func (*GitlabMRApproval) IsApproved ¶
func (gm *GitlabMRApproval) IsApproved() bool
type GitlabMRAuthor ¶
func (*GitlabMRAuthor) GetUsername ¶
func (ga *GitlabMRAuthor) GetUsername() string
type GitlabMRDiscussion ¶
type GitlabMRDiscussion struct {
*gogitlab.Discussion
}
func (*GitlabMRDiscussion) GetDiscussionID ¶
func (gd *GitlabMRDiscussion) GetDiscussionID() string
func (*GitlabMRDiscussion) GetMRNotes ¶
func (gd *GitlabMRDiscussion) GetMRNotes() []vcs.MRNote
type GitlabMRNote ¶
func (*GitlabMRNote) GetNoteID ¶
func (gn *GitlabMRNote) GetNoteID() int64
type GitlabMergeCommentEvent ¶
type GitlabMergeCommentEvent struct {
*gogitlab.MergeCommentEvent
}
func (*GitlabMergeCommentEvent) GetAttributes ¶
func (gE *GitlabMergeCommentEvent) GetAttributes() vcs.MRAttributes
func (*GitlabMergeCommentEvent) GetAuthor ¶
func (gE *GitlabMergeCommentEvent) GetAuthor() vcs.MRAuthor
func (*GitlabMergeCommentEvent) GetDiscussionID ¶
func (gE *GitlabMergeCommentEvent) GetDiscussionID() string
func (*GitlabMergeCommentEvent) GetEventSequence ¶ added in v0.7.0
func (gE *GitlabMergeCommentEvent) GetEventSequence() int64
func (*GitlabMergeCommentEvent) GetInternalID ¶
func (gE *GitlabMergeCommentEvent) GetInternalID() int
func (*GitlabMergeCommentEvent) GetLastCommit ¶
func (gE *GitlabMergeCommentEvent) GetLastCommit() vcs.Commit
func (*GitlabMergeCommentEvent) GetMR ¶
func (gE *GitlabMergeCommentEvent) GetMR() vcs.MR
func (*GitlabMergeCommentEvent) GetNote ¶
func (gE *GitlabMergeCommentEvent) GetNote() string
func (*GitlabMergeCommentEvent) GetPathWithNamespace ¶
func (gE *GitlabMergeCommentEvent) GetPathWithNamespace() string
func (*GitlabMergeCommentEvent) GetProject ¶
func (gE *GitlabMergeCommentEvent) GetProject() vcs.Project
func (*GitlabMergeCommentEvent) GetSHA ¶
func (gE *GitlabMergeCommentEvent) GetSHA() string
func (*GitlabMergeCommentEvent) GetSourceBranch ¶
func (gE *GitlabMergeCommentEvent) GetSourceBranch() string
func (*GitlabMergeCommentEvent) GetTargetBranch ¶
func (gE *GitlabMergeCommentEvent) GetTargetBranch() string
func (*GitlabMergeCommentEvent) GetType ¶
func (gE *GitlabMergeCommentEvent) GetType() string
func (*GitlabMergeCommentEvent) GetUsername ¶
func (gE *GitlabMergeCommentEvent) GetUsername() string
type GitlabPipeline ¶
type GitlabPipeline struct {
*gogitlab.PipelineInfo
}
func (*GitlabPipeline) GetID ¶
func (gP *GitlabPipeline) GetID() int
func (*GitlabPipeline) GetSource ¶
func (gP *GitlabPipeline) GetSource() string
func (*GitlabPipeline) GetStatus ¶ added in v0.6.0
func (gP *GitlabPipeline) GetStatus() string
func (*GitlabPipeline) GetWebURL ¶ added in v0.6.0
func (gP *GitlabPipeline) GetWebURL() string
type GitlabProjectSettings ¶ added in v0.6.0
func (*GitlabProjectSettings) OnlyAllowMergeIfPipelineSucceeds ¶ added in v0.6.0
func (gP *GitlabProjectSettings) OnlyAllowMergeIfPipelineSucceeds() bool
type RunStatusUpdater ¶
type RunStatusUpdater struct {
// contains filtered or unexported fields
}
func NewRunStatusProcessor ¶
func NewRunStatusProcessor(cfg config.Config, client *GitlabClient, rs runstream.StreamClient, tfc tfc_api.ApiClient) *RunStatusUpdater
func (*RunStatusUpdater) Close ¶
func (p *RunStatusUpdater) Close()