Documentation ¶
Overview ¶
Package gitlab is an internal wrapper for the go-gitlab package
Most functions serve to expose debug logging if set and accept a project name string over an ID.
Index ¶
- Constants
- Variables
- func AddIssueDiscussionNote(projID interface{}, issueID int, discussionID string, body string) (string, error)
- func AddMRDiscussionNote(projID interface{}, mrID int, discussionID string, body string) (string, error)
- func BranchList(projID interface{}, opts *gitlab.ListBranchesOptions) ([]*gitlab.Branch, error)
- func CIArtifacts(projID interface{}, id int, name, path string, followBridge bool, ...) (io.Reader, string, error)
- func CICancel(projID interface{}, jobID int) (*gitlab.Job, error)
- func CICreate(projID interface{}, opts *gitlab.CreatePipelineOptions) (*gitlab.Pipeline, error)
- func CIPlayOrRetry(projID interface{}, jobID int, status string) (*gitlab.Job, error)
- func CITrace(projID interface{}, id int, name string, followBridge bool, bridgeName string) (io.Reader, *gitlab.Job, error)
- func CITrigger(projID interface{}, opts gitlab.RunPipelineTriggerOptions) (*gitlab.Pipeline, error)
- func CreateCommitComment(projID interface{}, sha string, newFile string, oldFile string, line int, ...) (string, error)
- func CreateMergeRequestCommitDiscussion(projID interface{}, id int, sha string, newFile string, oldFile string, ...) (string, error)
- func FindProject(projID interface{}) (*gitlab.Project, error)
- func Fork(projID interface{}, opts *gitlab.ForkProjectOptions, useHTTP bool, wait bool) (string, error)
- func GetCommit(projID interface{}, ref string) (*gitlab.Commit, error)
- func GetCommitDiff(projID interface{}, sha string) ([]*gitlab.Diff, error)
- func GetMRApprovalsConfiguration(projID interface{}, id int) (*gitlab.MergeRequestApprovals, error)
- func GetProject(projID interface{}) (*gitlab.Project, error)
- func GroupSearch(query string) (*gitlab.Group, error)
- func Host() string
- func Init(_host, _user, _token string, allowInsecure bool)
- func InitWithCustomCA(_host, _user, _token, caFile string) error
- func IssueClose(projID interface{}, id int) error
- func IssueCreate(projID interface{}, opts *gitlab.CreateIssueOptions) (string, error)
- func IssueCreateNote(projID interface{}, id int, opts *gitlab.CreateIssueNoteOptions) (string, error)
- func IssueDeleteNote(projID interface{}, issue int, discussion string, note int) error
- func IssueDuplicate(projID interface{}, id int, dupID interface{}) error
- func IssueGet(projID interface{}, id int) (*gitlab.Issue, error)
- func IssueList(projID interface{}, opts gitlab.ListProjectIssuesOptions, n int) ([]*gitlab.Issue, error)
- func IssueListDiscussions(projID interface{}, id int) ([]*gitlab.Discussion, error)
- func IssueReopen(projID interface{}, id int) error
- func IssueSubscribe(projID interface{}, id int) error
- func IssueUnsubscribe(projID interface{}, id int) error
- func IssueUpdate(projID interface{}, id int, opts *gitlab.UpdateIssueOptions) (string, error)
- func LabelCreate(projID interface{}, opts *gitlab.CreateLabelOptions) error
- func LabelDelete(projID, name string) error
- func LabelList(projID interface{}) ([]*gitlab.Label, error)
- func Lint(content string) (bool, error)
- func ListIssuesClosedOnMerge(projID interface{}, id int) ([]int, error)
- func ListMRsClosingIssue(projID interface{}, id int) ([]int, error)
- func ListMRsRelatedToIssue(projID interface{}, id int) ([]int, error)
- func LoadGitLabTmpl(tmplName string) string
- func MRApprove(projID interface{}, id int) error
- func MRClose(projID interface{}, id int) error
- func MRCreate(projID interface{}, opts *gitlab.CreateMergeRequestOptions) (string, error)
- func MRCreateDiscussion(projID interface{}, id int, opts *gitlab.CreateMergeRequestDiscussionOptions) (string, error)
- func MRCreateNote(projID interface{}, id int, opts *gitlab.CreateMergeRequestNoteOptions) (string, error)
- func MRDelete(projID interface{}, id int) error
- func MRDeleteNote(projID interface{}, mr int, discussion string, note int) error
- func MRGet(projID interface{}, id int) (*gitlab.MergeRequest, error)
- func MRList(projID interface{}, opts gitlab.ListProjectMergeRequestsOptions, n int) ([]*gitlab.MergeRequest, error)
- func MRListDiscussions(projID interface{}, id int) ([]*gitlab.Discussion, error)
- func MRMerge(projID interface{}, id int, opts *gitlab.AcceptMergeRequestOptions) error
- func MRRebase(projID interface{}, id int) error
- func MRReopen(projID interface{}, id int) error
- func MRSubscribe(projID interface{}, id int) error
- func MRThumbDown(projID interface{}, id int) error
- func MRThumbUp(projID interface{}, id int) error
- func MRUnapprove(projID interface{}, id int) error
- func MRUnsubscribe(projID interface{}, id int) error
- func MRUpdate(projID interface{}, id int, opts *gitlab.UpdateMergeRequestOptions) (string, error)
- func MilestoneCreate(projID interface{}, opts *gitlab.CreateMilestoneOptions) error
- func MilestoneDelete(projID, name string) error
- func MilestoneGet(projID interface{}, name string) (*gitlab.Milestone, error)
- func MilestoneList(projID interface{}, opt *gitlab.ListMilestonesOptions) ([]*gitlab.Milestone, error)
- func MoveIssue(projID interface{}, id int, destProjID interface{}) (string, error)
- func ProjectCreate(opts *gitlab.CreateProjectOptions) (*gitlab.Project, error)
- func ProjectDelete(projID interface{}) error
- func ProjectList(opts gitlab.ListProjectsOptions, n int) ([]*gitlab.Project, error)
- func ProjectSnippetCreate(projID interface{}, opts *gitlab.CreateProjectSnippetOptions) (*gitlab.Snippet, error)
- func ProjectSnippetDelete(projID interface{}, id int) error
- func ProjectSnippetList(projID interface{}, opts gitlab.ListProjectSnippetsOptions, n int) ([]*gitlab.Snippet, error)
- func ResolveMRDiscussion(projID interface{}, mrID int, discussionID string, noteID int) (string, error)
- func SnippetCreate(opts *gitlab.CreateSnippetOptions) (*gitlab.Snippet, error)
- func SnippetDelete(id int) error
- func SnippetList(opts gitlab.ListSnippetsOptions, n int) ([]*gitlab.Snippet, error)
- func TodoIssueCreate(projID interface{}, id int) (int, error)
- func TodoList(opts gitlab.ListTodosOptions, n int) ([]*gitlab.Todo, error)
- func TodoMRCreate(projID interface{}, id int) (int, error)
- func TodoMarkAllDone() error
- func TodoMarkDone(id int) error
- func UpdateIssueDiscussionNote(projID interface{}, issueID int, discussionID string, noteID int, body string) (string, error)
- func UpdateMRDiscussionNote(projID interface{}, mrID int, discussionID string, noteID int, body string) (string, error)
- func User() string
- func UserID() (int, error)
- func UserIDFromEmail(email string) (int, error)
- func UserIDFromUsername(username string) (int, error)
- type JobStruct
Constants ¶
const ( TmplMR = "merge_request_templates/default.md" TmplIssue = "issue_templates/default.md" )
Defines filepath for default GitLab templates
Variables ¶
var ( // ErrActionRepeated is returned when a GitLab action is executed again. For example // this can be returned when an MR is approved twice. ErrActionRepeated = errors.New("GitLab action repeated") // ErrNotModified is returned when adding an already existing item to a Todo list ErrNotModified = errors.New("Not Modified") // ErrProjectNotFound is returned when a GitLab project cannot be found. ErrProjectNotFound = errors.New("GitLab project not found, verify you have access to the requested resource") // ErrStatusForbidden is returned when attempting to access a GitLab project with insufficient permissions ErrStatusForbidden = errors.New("Insufficient permissions for GitLab project") )
Functions ¶
func AddIssueDiscussionNote ¶ added in v0.21.0
func AddIssueDiscussionNote(projID interface{}, issueID int, discussionID string, body string) (string, error)
AddIssueDiscussionNote adds a note to an existing issue discussion on GitLab
func AddMRDiscussionNote ¶ added in v0.21.0
func AddMRDiscussionNote(projID interface{}, mrID int, discussionID string, body string) (string, error)
AddMRDiscussionNote adds a note to an existing MR discussion on GitLab
func BranchList ¶ added in v0.21.0
func BranchList(projID interface{}, opts *gitlab.ListBranchesOptions) ([]*gitlab.Branch, error)
BranchList get all branches from the project that somehow matches the requested options
func CIArtifacts ¶ added in v0.21.0
func CIArtifacts(projID interface{}, id int, name, path string, followBridge bool, bridgeName string) (io.Reader, string, error)
CIArtifacts searches by name for a job and returns its artifacts archive together with the upstream filename. If path is specified and refers to a single file within the artifacts archive, that file is returned instead. If no name is provided, the last job with an artifacts file is picked.
func CICreate ¶ added in v0.13.0
func CICreate(projID interface{}, opts *gitlab.CreatePipelineOptions) (*gitlab.Pipeline, error)
CICreate creates a pipeline for given ref
func CIPlayOrRetry ¶ added in v0.12.0
CIPlayOrRetry runs a job either by playing it for the first time or by retrying it based on the currently known job state
func CITrace ¶ added in v0.11.0
func CITrace(projID interface{}, id int, name string, followBridge bool, bridgeName string) (io.Reader, *gitlab.Job, error)
CITrace searches by name for a job and returns its trace file. The trace is static so may only be a portion of the logs if the job is till running. If no name is provided job is picked using the first available: 1. Last Running Job 2. First Pending Job 3. Last Job in Pipeline
func CITrigger ¶ added in v0.13.0
func CITrigger(projID interface{}, opts gitlab.RunPipelineTriggerOptions) (*gitlab.Pipeline, error)
CITrigger triggers a pipeline for given ref
func CreateCommitComment ¶ added in v0.23.0
func CreateMergeRequestCommitDiscussion ¶ added in v0.23.0
func FindProject ¶
FindProject looks up the Gitlab project. If the namespace is not provided in the project string it will search for projects in the users namespace
func Fork ¶
func Fork(projID interface{}, opts *gitlab.ForkProjectOptions, useHTTP bool, wait bool) (string, error)
Fork creates a user fork of a GitLab project using the specified protocol
func GetCommitDiff ¶ added in v0.23.0
func GetMRApprovalsConfiguration ¶ added in v0.21.0
func GetMRApprovalsConfiguration(projID interface{}, id int) (*gitlab.MergeRequestApprovals, error)
GetMRApprovalsConfiguration returns the current MR approval rule
func GetProject ¶ added in v0.10.0
GetProject looks up a Gitlab project by ID.
func GroupSearch ¶ added in v0.21.0
GroupSearch searches for a namespace on GitLab
func Host ¶ added in v0.6.0
func Host() string
Host exposes the GitLab scheme://hostname used to interact with the API
func InitWithCustomCA ¶ added in v0.21.0
InitWithCustomCA open the HTTP client using a custom CA file (a self signed one for instance) instead of relying only on those installed in the current system database
func IssueClose ¶ added in v0.8.0
IssueClose closes an issue on a GitLab project
func IssueCreate ¶
func IssueCreate(projID interface{}, opts *gitlab.CreateIssueOptions) (string, error)
IssueCreate opens a new issue on a GitLab project
func IssueCreateNote ¶ added in v0.15.0
func IssueCreateNote(projID interface{}, id int, opts *gitlab.CreateIssueNoteOptions) (string, error)
IssueCreateNote creates a new note on an issue and returns the note URL
func IssueDeleteNote ¶ added in v0.24.0
func IssueDuplicate ¶ added in v0.21.0
IssueDuplicate closes an issue as duplicate of another
func IssueList ¶
func IssueList(projID interface{}, opts gitlab.ListProjectIssuesOptions, n int) ([]*gitlab.Issue, error)
IssueList gets a list of issues on a GitLab Project
func IssueListDiscussions ¶ added in v0.15.0
func IssueListDiscussions(projID interface{}, id int) ([]*gitlab.Discussion, error)
IssueListDiscussions retrieves the discussions (aka notes & comments) for an issue
func IssueReopen ¶ added in v0.21.0
IssueReopen reopens a closed issue
func IssueSubscribe ¶ added in v0.21.0
IssueSubscribe subscribes to an issue on a GitLab project
func IssueUnsubscribe ¶ added in v0.21.0
IssueUnsubscribe unsubscribes from an issue on a GitLab project
func IssueUpdate ¶ added in v0.15.0
func IssueUpdate(projID interface{}, id int, opts *gitlab.UpdateIssueOptions) (string, error)
IssueUpdate edits an issue on a GitLab project
func LabelCreate ¶ added in v0.21.0
func LabelCreate(projID interface{}, opts *gitlab.CreateLabelOptions) error
LabelCreate creates a new project label
func LabelDelete ¶ added in v0.21.0
LabelDelete removes a project label
func ListIssuesClosedOnMerge ¶ added in v0.21.0
ListIssuesClosedOnMerge retuns a list of issue numbers that were closed by an MR being merged
func ListMRsClosingIssue ¶ added in v0.21.0
ListMRsClosingIssue returns a list of MR IDs that has relation to an issue being closed
func ListMRsRelatedToIssue ¶ added in v0.21.0
ListMRsRelatedToIssue return a list of MR IDs that has any relations to a certain issue
func LoadGitLabTmpl ¶ added in v0.5.1
LoadGitLabTmpl loads gitlab templates for use in creating Issues and MRs
func MRCreate ¶ added in v0.8.0
func MRCreate(projID interface{}, opts *gitlab.CreateMergeRequestOptions) (string, error)
MRCreate opens a merge request on GitLab
func MRCreateDiscussion ¶ added in v0.21.0
func MRCreateDiscussion(projID interface{}, id int, opts *gitlab.CreateMergeRequestDiscussionOptions) (string, error)
MRCreateDiscussion creates a discussion on a merge request on GitLab
func MRCreateNote ¶ added in v0.16.0
func MRCreateNote(projID interface{}, id int, opts *gitlab.CreateMergeRequestNoteOptions) (string, error)
MRCreateNote adds a note to a merge request on GitLab
func MRDeleteNote ¶ added in v0.24.0
func MRGet ¶ added in v0.8.0
func MRGet(projID interface{}, id int) (*gitlab.MergeRequest, error)
MRGet retrieves the merge request from GitLab project
func MRList ¶ added in v0.8.0
func MRList(projID interface{}, opts gitlab.ListProjectMergeRequestsOptions, n int) ([]*gitlab.MergeRequest, error)
MRList lists the MRs on a GitLab project
func MRListDiscussions ¶ added in v0.21.0
func MRListDiscussions(projID interface{}, id int) ([]*gitlab.Discussion, error)
MRListDiscussions retrieves the discussions (aka notes & comments) for a merge request
func MRMerge ¶ added in v0.8.0
func MRMerge(projID interface{}, id int, opts *gitlab.AcceptMergeRequestOptions) error
MRMerge merges an mr on a GitLab project
func MRSubscribe ¶ added in v0.21.0
MRSubscribe subscribes to an mr on a GitLab project
func MRThumbDown ¶ added in v0.13.0
MRThumbDown places a thumb up/down on a merge request
func MRUnapprove ¶ added in v0.21.0
MRUnapprove Unapproves a previously approved mr on a GitLab project
func MRUnsubscribe ¶ added in v0.21.0
MRUnsubscribe unsubscribes from a previously mr on a GitLab project
func MRUpdate ¶ added in v0.21.0
func MRUpdate(projID interface{}, id int, opts *gitlab.UpdateMergeRequestOptions) (string, error)
MRUpdate edits an merge request on a GitLab project
func MilestoneCreate ¶ added in v0.21.0
func MilestoneCreate(projID interface{}, opts *gitlab.CreateMilestoneOptions) error
MilestoneCreate creates a new project milestone
func MilestoneDelete ¶ added in v0.21.0
MilestoneDelete deletes a project milestone
func MilestoneGet ¶ added in v0.21.0
MilestoneGet get a specific milestone from the list of available ones
func MilestoneList ¶ added in v0.21.0
func MilestoneList(projID interface{}, opt *gitlab.ListMilestonesOptions) ([]*gitlab.Milestone, error)
MilestoneList gets a list of milestones on a GitLab Project
func ProjectCreate ¶ added in v0.10.0
func ProjectCreate(opts *gitlab.CreateProjectOptions) (*gitlab.Project, error)
ProjectCreate creates a new project on GitLab
func ProjectDelete ¶ added in v0.10.0
func ProjectDelete(projID interface{}) error
ProjectDelete creates a new project on GitLab
func ProjectList ¶ added in v0.12.0
ProjectList gets a list of projects on GitLab
func ProjectSnippetCreate ¶ added in v0.6.0
func ProjectSnippetCreate(projID interface{}, opts *gitlab.CreateProjectSnippetOptions) (*gitlab.Snippet, error)
ProjectSnippetCreate creates a snippet in a project
func ProjectSnippetDelete ¶ added in v0.6.0
ProjectSnippetDelete deletes a project snippet
func ProjectSnippetList ¶ added in v0.6.0
func ProjectSnippetList(projID interface{}, opts gitlab.ListProjectSnippetsOptions, n int) ([]*gitlab.Snippet, error)
ProjectSnippetList lists snippets on a project
func ResolveMRDiscussion ¶ added in v0.21.0
func ResolveMRDiscussion(projID interface{}, mrID int, discussionID string, noteID int) (string, error)
ResolveMRDiscussion resolves a discussion (blocking thread) based on its ID
func SnippetCreate ¶ added in v0.6.0
func SnippetCreate(opts *gitlab.CreateSnippetOptions) (*gitlab.Snippet, error)
SnippetCreate creates a personal snippet
func SnippetDelete ¶ added in v0.6.0
SnippetDelete deletes a personal snippet
func SnippetList ¶ added in v0.6.0
SnippetList lists snippets on a project
func TodoIssueCreate ¶ added in v0.23.0
TodoIssueCreate create a Todo item for an specific Issue
func TodoList ¶ added in v0.22.0
TodoList retuns a list of *gitlab.Todo refering to user's Todo list
func TodoMRCreate ¶ added in v0.22.0
TodoMRCreate create a Todo item for an specific MR
func TodoMarkAllDone ¶ added in v0.22.0
func TodoMarkAllDone() error
TodoMarkAllDone marks all Todos items as done
func TodoMarkDone ¶ added in v0.22.0
TodoMarkDone marks a specific Todo as done
func UpdateIssueDiscussionNote ¶ added in v0.21.0
func UpdateIssueDiscussionNote(projID interface{}, issueID int, discussionID string, noteID int, body string) (string, error)
UpdateIssueDiscussionNote updates a specific discussion or note in the specified issue number
func UpdateMRDiscussionNote ¶ added in v0.21.0
func UpdateMRDiscussionNote(projID interface{}, mrID int, discussionID string, noteID int, body string) (string, error)
UpdateMRDiscussionNote updates a specific discussion or note in the specified MR ID.
func UserIDFromEmail ¶ added in v0.22.0
UserIDFromEmail returns the associated Users ID in GitLab. This is useful for API calls that allow you to reference a user, but only by ID.
func UserIDFromUsername ¶ added in v0.12.0
UserIDFromUsername returns the associated Users ID in GitLab. This is useful for API calls that allow you to reference a user, but only by ID.
Types ¶
type JobStruct ¶ added in v0.21.0
type JobStruct struct { Job *gitlab.Job // A project ID can either be a string or an integer ProjectID interface{} }
JobStruct maps the project ID to which a certain job belongs to. It's needed due to multi-projects pipeline, which allows jobs from different projects be triggered by the current project. CIJob() is currently the function handling the mapping.