gitlabclient

package
v0.0.0-...-d654738 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ActionOpened  = "opened"
	ActionCreated = "created"
	ActionReopen  = "reopened"
	ActionClosed  = "closed"
)

Variables

This section is empty.

Functions

func CheckLabelUpdate

func CheckLabelUpdate(e *gitlab.MergeEvent) (labelUpdated bool)

func CheckSourceBranchChanged

func CheckSourceBranchChanged(e *gitlab.MergeEvent) (changed bool)

func GetIssueAuthor

func GetIssueAuthor(e *gitlab.IssueEvent) (author string)

func GetIssueCommentAuthor

func GetIssueCommentAuthor(e *gitlab.IssueCommentEvent) (author string)

func GetIssueCommentAuthorID

func GetIssueCommentAuthorID(e *gitlab.IssueCommentEvent) (authorID int)

func GetIssueCommentBody

func GetIssueCommentBody(e *gitlab.IssueCommentEvent) (comment string)

func GetIssueCommentOrgAndRepo

func GetIssueCommentOrgAndRepo(e *gitlab.IssueCommentEvent) (org, repo string)

func GetIssueNumber

func GetIssueNumber(e *gitlab.IssueEvent) (issueID int)

func GetIssueOrgAndRepo

func GetIssueOrgAndRepo(e *gitlab.IssueEvent) (org, repo string)

func GetMRAuthor

func GetMRAuthor(e *gitlab.MergeEvent) (author string)

func GetMRCommentAuthor

func GetMRCommentAuthor(e *gitlab.MergeCommentEvent) (author string)

func GetMRCommentAuthorID

func GetMRCommentAuthorID(e *gitlab.MergeCommentEvent) (authorID int)

func GetMRCommentBody

func GetMRCommentBody(e *gitlab.MergeCommentEvent) (comment string)

func GetMRCommentOrgAndRepo

func GetMRCommentOrgAndRepo(e *gitlab.MergeCommentEvent) (org, repo string)

func GetMRNumber

func GetMRNumber(e *gitlab.MergeEvent) (mrID int)

func GetMROrgAndRepo

func GetMROrgAndRepo(e *gitlab.MergeEvent) (org, repo string)

func GetOrgRepo

func GetOrgRepo(orgPath string) (string, string)

GetOrgRepo return the owner and name of the project

func ValidateWebhook

func ValidateWebhook(
	w http.ResponseWriter,
	r *http.Request,
	tokenGenerator func() string,
) (eType string, eventGUID string, ua string, payload []byte, ok bool, status int)

ValidateWebhook ensures that the provided request conforms to the format of a GitLab webhook and the payload can be validated with the provided hmac secret. It returns the event type, the event guid, the payload of the request, whether the webhook is valid or not, and finally the resultant HTTP status code

Types

type Client

type Client interface {
	UpdateMergeRequest(projectID interface{}, mrID int, options gitlab.UpdateMergeRequestOptions) (gitlab.MergeRequest, error)
	GetMergeRequest(projectID interface{}, mrID int) (gitlab.MergeRequest, error)
	ListCollaborators(projectID interface{}) ([]*gitlab.ProjectMember, error)
	IsCollaborator(projectID interface{}, loginID int) (bool, error)
	AddProjectMember(projectID interface{}, loginID interface{}, accessLevel int) error
	RemoveProjectMember(projectID interface{}, loginID int) error
	IsMember(groupID interface{}, userID int) (bool, error)
	GetMergeRequestChanges(projectID interface{}, mrID int) ([]string, error)
	GetMergeRequestLabels(projectID interface{}, mrID int) (gitlab.Labels, error)
	ListMergeRequestComments(projectID interface{}, mrID int) ([]*gitlab.Note, error)
	ListIssues(projectID interface{}) ([]*gitlab.Issue, error)
	ListIssueRelatedMergeRequest(projectID interface{}, issueID int) ([]*gitlab.MergeRequest, error)
	UpdateMergeRequestComment(projectID interface{}, mrID, noteID int, comment string) error
	CreateMergeRequestComment(projectID interface{}, mrID int, comment string) error
	DeleteMergeRequestComment(projectID interface{}, mrID int, noteID int) error
	AddMergeRequestLabel(projectID interface{}, mrID int, labels gitlab.Labels) error
	RemoveMergeRequestLabel(projectID interface{}, mrID int, labels gitlab.Labels) error
	ReplaceMergeRequestAllLabels(projectID interface{}, mrID int, labels gitlab.Labels) error
	ReopenMergeRequest(projectID interface{}, mrID int, state string) error
	CloseMergeRequest(projectID interface{}, mrID int, state string) error
	AssignMergeRequest(projectID interface{}, mrID int, ids []int) error
	UnAssignMergeRequest(projectID interface{}, mrID int, ids []int) error
	GetMergeRequestCommits(projectID interface{}, mrID int) ([]*gitlab.Commit, error)
	GetSingleRepoCommit(projectID interface{}, sha string) (*gitlab.Commit, error)
	MergeMergeRequest(projectID interface{}, mrID int) error
	GetGroups() ([]*gitlab.Group, error)
	GetProjects(gid interface{}) ([]*gitlab.Project, error)
	GetProject(projectID interface{}) (*gitlab.Project, error)
	CreateProject(opts gitlab.CreateProjectOptions) (*gitlab.Project, error)
	UpdateProject(projectID interface{}, opts gitlab.EditProjectOptions) error
	AddProjectLabel(projectID interface{}, label, color string) error
	UpdateProjectLabel(projectID interface{}, oldLabel, label, color string) error
	GetProjectLabels(projectID interface{}) ([]*gitlab.Label, error)
	AssignIssue(projectID interface{}, issueID int, assignees []int) error
	UpdateIssue(projectID interface{}, issueID int, opts gitlab.UpdateIssueOptions) error
	CreateIssue(projectID interface{}, opts gitlab.CreateIssueOptions) error
	UnAssignIssue(projectID interface{}, issueID int, assignees []int) error
	RemoveAssignIssue(projectID interface{}, issueID int) error
	CreateIssueComment(projectID interface{}, issueID int, comment string) error
	ListIssueComments(projectID interface{}, issueID int) ([]*gitlab.Note, error)
	UpdateIssueComment(projectID interface{}, issueID, noteID int, comment string) error
	RemoveIssueComment(projectID interface{}, issueID, noteID int) error
	GetIssueLabels(projectID interface{}, issueID int) ([]string, error)
	RemoveIssueLabels(projectID interface{}, issueID int, labels gitlab.Labels) error
	AddIssueLabels(projectID interface{}, issueID int, labels gitlab.Labels) error
	CloseIssue(projectID interface{}, issueID int) error
	ReopenIssue(projectID interface{}, issueID int) error
	GetSingleIssue(projectID interface{}, issueID int) (*gitlab.Issue, error)
	CreateBranch(projectID interface{}, branch, ref string) error
	GetProjectAllBranches(projectID interface{}) ([]*gitlab.Branch, error)
	SetProtectionBranch(projectID interface{}, branch string) error
	UnProtectBranch(projectID interface{}, branch string) error
	CreateFile(projectID interface{}, file string, opts gitlab.CreateFileOptions) error
	GetPathContent(projectID interface{}, file, branch string) (*gitlab.File, error)
	GetDirectoryTree(projectID interface{}, opts gitlab.ListTreeOptions) ([]*gitlab.TreeNode, error)
	GetUserPermissionOfProject(projectID interface{}, userID int) (bool, error)
	GetMergeRequestLabelChanges(projectID interface{}, mrID int) ([]*gitlab.LabelEvent, error)
	CreateProjectLabel(projectID interface{}, label, color string) error
	GetSingleUser(name string) int
	TransferProjectNameSpace(projectID interface{}, newNameSpace string) error
	PatchFile(projectID interface{}, filePath, content, branch, message string) error
}

func NewGitlabClient

func NewGitlabClient(getToken func() []byte, host string) Client

type ErrorForbidden

type ErrorForbidden struct {
	// contains filtered or unexported fields
}

func (ErrorForbidden) Error

func (e ErrorForbidden) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL