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(project string, issueNum int, discussionID string, body string) (string, error)
- func AddMRDiscussionNote(project string, mrNum int, discussionID string, body string) (string, error)
- func BranchList(project string, opts *gitlab.ListBranchesOptions) ([]*gitlab.Branch, error)
- func CIArtifacts(pid interface{}, id int, name, path string, followBridge bool) (io.Reader, string, error)
- func CICancel(pid interface{}, jobID int) (*gitlab.Job, error)
- func CICreate(pid interface{}, opts *gitlab.CreatePipelineOptions) (*gitlab.Pipeline, error)
- func CIPlayOrRetry(pid interface{}, jobID int, status string) (*gitlab.Job, error)
- func CITrace(pid interface{}, id int, name string, followBridge bool) (io.Reader, *gitlab.Job, error)
- func CITrigger(pid interface{}, opts gitlab.RunPipelineTriggerOptions) (*gitlab.Pipeline, error)
- func FileGet(project string, fileName string, ref string) (string, error)
- func FindProject(project string) (*gitlab.Project, error)
- func Fork(project string, opts *gitlab.ForkProjectOptions, useHTTP bool, wait bool) (string, error)
- func GetCommit(pid interface{}, ref string) (*gitlab.Commit, error)
- func GetCommitMergeRequest(pid interface{}, sha string) ([]*gitlab.MergeRequest, error)
- func GetMRApprovalState(project string, mrNum int) (*gitlab.MergeRequestApprovalState, error)
- func GetMRApprovalsConfiguration(project string, mrNum int) (*gitlab.MergeRequestApprovals, error)
- func GetProject(projectID interface{}) (*gitlab.Project, error)
- func GroupSearch(query string) (*gitlab.Group, error)
- func Host() string
- func Init(_host, _user, _token string)
- func InitWithCustomCA(_host, _user, _token, caFile string) error
- func IssueClose(pid interface{}, id int) error
- func IssueCreate(project string, opts *gitlab.CreateIssueOptions) (string, error)
- func IssueCreateNote(project string, issueNum int, opts *gitlab.CreateIssueNoteOptions) (string, error)
- func IssueDuplicate(pid interface{}, id int, dupId string) error
- func IssueGet(project interface{}, issueNum int) (*gitlab.Issue, error)
- func IssueList(project string, opts gitlab.ListProjectIssuesOptions, n int) ([]*gitlab.Issue, error)
- func IssueListDiscussions(project string, issueNum int) ([]*gitlab.Discussion, error)
- func IssueReopen(pid interface{}, id int) error
- func IssueSubscribe(pid interface{}, id int) error
- func IssueUnsubscribe(pid interface{}, id int) error
- func IssueUpdate(project string, issueNum int, opts *gitlab.UpdateIssueOptions) (string, error)
- func LabelCreate(project string, opts *gitlab.CreateLabelOptions) error
- func LabelDelete(project, name string) error
- func LabelList(project string) ([]*gitlab.Label, error)
- func Lint(content string) (bool, error)
- func ListIssuesClosedOnMerge(project string, mrNum int) ([]int, error)
- func ListMRsClosingIssue(project string, issueNum int) ([]int, error)
- func ListMRsRelatedToIssue(project string, issueNum int) ([]int, error)
- func LoadGitLabTmpl(tmplName string) string
- func MRApprove(pid interface{}, id int) error
- func MRClose(pid interface{}, id int) error
- func MRCreate(project string, opts *gitlab.CreateMergeRequestOptions) (string, error)
- func MRCreateDiscussion(project string, mrNum int, opts *gitlab.CreateMergeRequestDiscussionOptions) (string, error)
- func MRCreateNote(project string, mrNum int, opts *gitlab.CreateMergeRequestNoteOptions) (string, error)
- func MRDelete(project string, mrNum int) error
- func MRGet(project interface{}, mrNum int) (*gitlab.MergeRequest, error)
- func MRList(project string, opts gitlab.ListProjectMergeRequestsOptions, n int) ([]*gitlab.MergeRequest, error)
- func MRListDiscussions(project string, mrNum int) ([]*gitlab.Discussion, error)
- func MRMerge(pid interface{}, id int, opts *gitlab.AcceptMergeRequestOptions) error
- func MRRebase(pid interface{}, id int) error
- func MRReopen(pid interface{}, id int) error
- func MRSubscribe(pid interface{}, id int) error
- func MRThumbDown(pid interface{}, id int) error
- func MRThumbUp(pid interface{}, id int) error
- func MRUnapprove(pid interface{}, id int) error
- func MRUnsubscribe(pid interface{}, id int) error
- func MRUpdate(project string, mrNum int, opts *gitlab.UpdateMergeRequestOptions) (string, error)
- func MilestoneCreate(project string, opts *gitlab.CreateMilestoneOptions) error
- func MilestoneDelete(project, name string) error
- func MilestoneGet(project string, name string) (*gitlab.Milestone, error)
- func MilestoneList(project string, opt *gitlab.ListMilestonesOptions) ([]*gitlab.Milestone, error)
- func MoveIssue(project string, issueNum int, dest string) (string, error)
- func ProjectCreate(opts *gitlab.CreateProjectOptions) (*gitlab.Project, error)
- func ProjectDelete(pid interface{}) error
- func ProjectList(opts gitlab.ListProjectsOptions, n int) ([]*gitlab.Project, error)
- func ProjectSnippetCreate(pid interface{}, opts *gitlab.CreateProjectSnippetOptions) (*gitlab.Snippet, error)
- func ProjectSnippetDelete(pid interface{}, id int) error
- func ProjectSnippetList(pid interface{}, opts gitlab.ListProjectSnippetsOptions, n int) ([]*gitlab.Snippet, error)
- func ResolveMRDiscussion(project string, mrNum 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 TodoList(opts gitlab.ListTodosOptions, n int) ([]*gitlab.Todo, error)
- func TodoMRCreate(project string, mrNum int) (int, error)
- func TodoMarkAllDone() error
- func TodoMarkDone(todoNum int) error
- func UpdateIssueDiscussionNote(project string, issueNum int, discussionID string, noteID int, body string) (string, error)
- func UpdateMRDiscussionNote(project string, issueNum 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 JobSorter
- 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") // ErrGroupNotFound is returned when a GitLab group cannot be found. ErrGroupNotFound = errors.New("GitLab group not found") // 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 ¶
func AddIssueDiscussionNote(project string, issueNum int, discussionID string, body string) (string, error)
AddIssueDiscussionNote adds a note to an existing issue discussion on GitLab
func AddMRDiscussionNote ¶
func AddMRDiscussionNote(project string, mrNum int, discussionID string, body string) (string, error)
AddMRDiscussionNote adds a note to an existing MR discussion on GitLab
func BranchList ¶
BranchList get all branches from the project that somehow matches the requested options
func CIArtifacts ¶
func CIArtifacts(pid interface{}, id int, name, path string, followBridge bool) (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 ¶
func CICreate(pid interface{}, opts *gitlab.CreatePipelineOptions) (*gitlab.Pipeline, error)
CICreate creates a pipeline for given ref
func CIPlayOrRetry ¶
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 ¶
func CITrace(pid interface{}, id int, name string, followBridge bool) (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 ¶
func CITrigger(pid interface{}, opts gitlab.RunPipelineTriggerOptions) (*gitlab.Pipeline, error)
CITrigger triggers a pipeline for given ref
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 GetCommitMergeRequest ¶
func GetCommitMergeRequest(pid interface{}, sha string) ([]*gitlab.MergeRequest, error)
func GetMRApprovalState ¶
func GetMRApprovalState(project string, mrNum int) (*gitlab.MergeRequestApprovalState, error)
func GetMRApprovalsConfiguration ¶
func GetMRApprovalsConfiguration(project string, mrNum int) (*gitlab.MergeRequestApprovals, error)
func GetProject ¶
GetProject looks up a Gitlab project by ID.
func GroupSearch ¶
GroupSearch searches for a namespace on GitLab
func Host ¶
func Host() string
Host exposes the GitLab scheme://hostname used to interact with the API
func Init ¶
func Init(_host, _user, _token string)
Init initializes a gitlab client for use throughout lab.
func InitWithCustomCA ¶
func IssueClose ¶
IssueClose closes an issue on a GitLab project
func IssueCreate ¶
func IssueCreate(project string, opts *gitlab.CreateIssueOptions) (string, error)
IssueCreate opens a new issue on a GitLab project
func IssueCreateNote ¶
func IssueCreateNote(project string, issueNum int, opts *gitlab.CreateIssueNoteOptions) (string, error)
IssueCreateNote creates a new note on an issue and returns the note URL
func IssueDuplicate ¶
IssueDuplicate closes an issue as duplicate of another
func IssueList ¶
func IssueList(project string, opts gitlab.ListProjectIssuesOptions, n int) ([]*gitlab.Issue, error)
IssueList gets a list of issues on a GitLab Project
func IssueListDiscussions ¶
func IssueListDiscussions(project string, issueNum int) ([]*gitlab.Discussion, error)
IssueListDiscussions retrieves the discussions (aka notes & comments) for an issue
func IssueReopen ¶
IssueReopen reopens a closed issue
func IssueSubscribe ¶
IssueSubscribe subscribes to an issue on a GitLab project
func IssueUnsubscribe ¶
IssueUnsubscribe unsubscribes from an issue on a GitLab project
func IssueUpdate ¶
IssueUpdate edits an issue on a GitLab project
func LabelCreate ¶
func LabelCreate(project string, opts *gitlab.CreateLabelOptions) error
LabelCreate creates a new project label
func ListIssuesClosedOnMerge ¶
func ListMRsRelatedToIssue ¶
func LoadGitLabTmpl ¶
LoadGitLabTmpl loads gitlab templates for use in creating Issues and MRs
func MRCreate ¶
func MRCreate(project string, opts *gitlab.CreateMergeRequestOptions) (string, error)
MRCreate opens a merge request on GitLab
func MRCreateDiscussion ¶
func MRCreateDiscussion(project string, mrNum int, opts *gitlab.CreateMergeRequestDiscussionOptions) (string, error)
MRCreateDiscussion creates a discussion on a merge request on GitLab
func MRCreateNote ¶
func MRCreateNote(project string, mrNum int, opts *gitlab.CreateMergeRequestNoteOptions) (string, error)
MRCreateNote adds a note to a merge request on GitLab
func MRGet ¶
func MRGet(project interface{}, mrNum int) (*gitlab.MergeRequest, error)
MRGet retrieves the merge request from GitLab project
func MRList ¶
func MRList(project string, opts gitlab.ListProjectMergeRequestsOptions, n int) ([]*gitlab.MergeRequest, error)
MRList lists the MRs on a GitLab project
func MRListDiscussions ¶
func MRListDiscussions(project string, mrNum int) ([]*gitlab.Discussion, error)
MRListDiscussions retrieves the discussions (aka notes & comments) for a merge request
func MRMerge ¶
func MRMerge(pid interface{}, id int, opts *gitlab.AcceptMergeRequestOptions) error
MRMerge merges an mr on a GitLab project
func MRSubscribe ¶
MRSubscribe subscribes to an mr on a GitLab project
func MRThumbDown ¶
MRThumbDown places a thumb up/down on a merge request
func MRUnapprove ¶
MRUnapprove Unapproves a previously approved mr on a GitLab project
func MRUnsubscribe ¶
MRUnsubscribe unsubscribes from a previously mr on a GitLab project
func MilestoneCreate ¶
func MilestoneCreate(project string, opts *gitlab.CreateMilestoneOptions) error
MilestoneCreate creates a new project milestone
func MilestoneDelete ¶
MilestoneDelete deletes a project milestone
func MilestoneList ¶
MilestoneList gets a list of milestones on a GitLab Project
func ProjectCreate ¶
func ProjectCreate(opts *gitlab.CreateProjectOptions) (*gitlab.Project, error)
ProjectCreate creates a new project on GitLab
func ProjectDelete ¶
func ProjectDelete(pid interface{}) error
ProjectDelete creates a new project on GitLab
func ProjectList ¶
ProjectList gets a list of projects on GitLab
func ProjectSnippetCreate ¶
func ProjectSnippetCreate(pid interface{}, opts *gitlab.CreateProjectSnippetOptions) (*gitlab.Snippet, error)
ProjectSnippetCreate creates a snippet in a project
func ProjectSnippetDelete ¶
ProjectSnippetDelete deletes a project snippet
func ProjectSnippetList ¶
func ProjectSnippetList(pid interface{}, opts gitlab.ListProjectSnippetsOptions, n int) ([]*gitlab.Snippet, error)
ProjectSnippetList lists snippets on a project
func ResolveMRDiscussion ¶
func SnippetCreate ¶
func SnippetCreate(opts *gitlab.CreateSnippetOptions) (*gitlab.Snippet, error)
SnippetCreate creates a personal snippet
func SnippetList ¶
SnippetList lists snippets on a project
func TodoMarkAllDone ¶
func TodoMarkAllDone() error
func TodoMarkDone ¶
func UpdateMRDiscussionNote ¶
func UserIDFromEmail ¶
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 ¶
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 ¶
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.