gitlab

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(secret, headerToken string) error

Validate validates the webhook payload

Types

type BranchResponse added in v0.3.0

type BranchResponse struct {
	Name   string `json:"name"`
	Commit struct {
		ID    string `json:"id"`
		Title string `json:"title"`
	}
}

BranchResponse is a respond struct for branch request

type Client

type Client struct {
	IntegrationConfig *cicdv1.IntegrationConfig
	K8sClient         client.Client
	// contains filtered or unexported fields
}

Client is a gitlab client struct

func (*Client) CanUserWriteToRepo added in v0.2.0

func (c *Client) CanUserWriteToRepo(user git.User) (bool, error)

CanUserWriteToRepo decides if the user has write permission on the repo

func (*Client) DeleteLabel added in v0.3.0

func (c *Client) DeleteLabel(issueType git.IssueType, id int, label string) error

DeleteLabel deletes label from the issue id

func (*Client) DeleteWebhook

func (c *Client) DeleteWebhook(id int) error

DeleteWebhook deletes registered webhook

func (*Client) GetBranch added in v0.3.0

func (c *Client) GetBranch(branch string) (*git.Branch, error)

GetBranch gets branch info

func (*Client) GetPullRequest added in v0.3.0

func (c *Client) GetPullRequest(id int) (*git.PullRequest, error)

GetPullRequest gets pull request info

func (*Client) GetPullRequestDiff added in v0.3.2

func (c *Client) GetPullRequestDiff(id int) (*git.Diff, error)

GetPullRequestDiff gets diff of the pull request

func (*Client) GetUserInfo added in v0.1.4

func (c *Client) GetUserInfo(userID string) (*git.User, error)

GetUserInfo gets a user's information

func (*Client) Init added in v0.2.3

func (c *Client) Init() error

Init initiates the Client

func (*Client) ListComments added in v0.5.3

func (c *Client) ListComments(issueNo int) ([]git.IssueComment, error)

ListComments lists comments of the issue id TODO: Consider Gitlab approve

func (*Client) ListCommitStatuses added in v0.3.0

func (c *Client) ListCommitStatuses(ref string) ([]git.CommitStatus, error)

ListCommitStatuses lists commit status of the specific commit

func (*Client) ListLabels added in v0.5.3

func (c *Client) ListLabels(id int) ([]git.IssueLabel, error)

ListLabels lists labels of pr id

func (*Client) ListPullRequestCommits added in v0.4.0

func (c *Client) ListPullRequestCommits(id int) ([]git.Commit, error)

ListPullRequestCommits lists commits list of a pull request

func (*Client) ListPullRequests added in v0.3.0

func (c *Client) ListPullRequests(onlyOpen bool) ([]git.PullRequest, error)

ListPullRequests gets pull request list

func (*Client) ListWebhook

func (c *Client) ListWebhook() ([]git.WebhookEntry, error)

ListWebhook lists registered webhooks

func (*Client) MergePullRequest added in v0.3.0

func (c *Client) MergePullRequest(id int, sha string, method git.MergeMethod, msg string) error

MergePullRequest merges a pull request

func (*Client) ParseWebhook

func (c *Client) ParseWebhook(header http.Header, jsonString []byte) (*git.Webhook, error)

ParseWebhook parses a webhook body for gitlab

func (*Client) RegisterComment added in v0.2.0

func (c *Client) RegisterComment(issueType git.IssueType, issueNo int, sha, body string) error

RegisterComment registers comment to an issue

func (*Client) RegisterWebhook

func (c *Client) RegisterWebhook(uri string) error

RegisterWebhook registers our webhook server to the remote git server

func (*Client) SetCommitStatus

func (c *Client) SetCommitStatus(sha string, status git.CommitStatus) error

SetCommitStatus sets commit status for the specific commit

func (*Client) SetLabel added in v0.3.0

func (c *Client) SetLabel(issueType git.IssueType, id int, label string) error

SetLabel sets label to the issue id

type CommentBody added in v0.2.0

type CommentBody struct {
	Body string `json:"body"`
}

CommentBody is a body structure for creating new comment

type CommitCommentBody added in v0.5.3

type CommitCommentBody struct {
	Note string `json:"note"`
}

CommitCommentBody is a body structure for creating new commit comment

type CommitResponse added in v0.4.0

type CommitResponse struct {
	ID             string `json:"id"`
	Message        string `json:"message"`
	AuthorName     string `json:"author_name"`
	AuthorEmail    string `json:"author_email"`
	CommitterName  string `json:"committer_name"`
	CommitterEmail string `json:"committer_email"`
}

CommitResponse is a commits list response

type CommitStatusRequest added in v0.3.0

type CommitStatusRequest struct {
	State       string `json:"state"`
	TargetURL   string `json:"target_url"`
	Description string `json:"description"`
	Context     string `json:"context"`
}

CommitStatusRequest is an API body for setting commits' status

type CommitStatusResponse added in v0.3.0

type CommitStatusResponse struct {
	Name        string `json:"name"`
	Status      string `json:"status"`
	Description string `json:"description"`
	TargetURL   string `json:"target_url"`
}

CommitStatusResponse is a response body of getting commit status

type Label added in v0.3.1

type Label struct {
	Title string `json:"title"`
}

Label is a label struct of an issue/merge request

type MergeAcceptRequest added in v0.3.0

type MergeAcceptRequest struct {
	MergeCommitMessage  string `json:"merge_commit_message,omitempty"`
	SquashCommitMessage string `json:"squash_commit_message,omitempty"`
	Squash              bool   `json:"squash"`
	Sha                 string `json:"sha"`
	RemoveSourceBranch  bool   `json:"should_remove_source_branch"`
}

MergeAcceptRequest is a request struct to merge a merge request

type MergeRequest added in v0.3.0

type MergeRequest struct {
	ID     int    `json:"iid"`
	Title  string `json:"title"`
	State  string `json:"state"`
	Author struct {
		ID       int    `json:"id"`
		UserName string `json:"username"`
	} `json:"author"`
	WebURL       string   `json:"web_url"`
	TargetBranch string   `json:"target_branch"`
	SourceBranch string   `json:"source_branch"`
	SHA          string   `json:"sha"`
	Labels       []string `json:"labels"`
	HasConflicts bool     `json:"has_conflicts"`
}

MergeRequest is a body struct of a merge request

type MergeRequestChanges added in v0.3.2

type MergeRequestChanges struct {
	Changes []struct {
		OldPath string `json:"old_path"`
		NewPath string `json:"new_path"`
		Diff    string `json:"diff"`
	} `json:"changes"`
}

MergeRequestChanges is a changed list of the merge request

type MergeRequestWebhook

type MergeRequestWebhook struct {
	Kind            string `json:"kind"`
	User            User   `json:"user"`
	ObjectAttribute struct {
		AuthorID   int    `json:"author_id"`
		Title      string `json:"title"`
		ID         int    `json:"iid"`
		BaseRef    string `json:"target_branch"`
		HeadRef    string `json:"source_branch"`
		LastCommit struct {
			Sha string `json:"id"`
		} `json:"last_commit"`
		State  string `json:"state"`
		Action string `json:"action"`
		OldRev string `json:"oldrev"`
	} `json:"object_attributes"`
	Project Project `json:"project"`
	Labels  []Label `json:"labels"`
	Changes struct {
		Labels *struct {
			Previous []Label `json:"previous"`
			Current  []Label `json:"current"`
		} `json:"labels,omitempty"`
	} `json:"changes"`
}

MergeRequestWebhook is a gitlab-specific merge-request event webhook body

type NoteHook added in v0.2.0

type NoteHook struct {
	User             User    `json:"user"`
	Project          Project `json:"project"`
	ObjectAttributes struct {
		Note      string     `json:"note"`
		AuthorID  int        `json:"author_id"`
		CreatedAt gitlabTime `json:"created_at"`
		UpdatedAt gitlabTime `json:"updated_at"`
	} `json:"object_attributes"`
	MergeRequest NoteMR `json:"merge_request"`
	Commit       struct {
		ID      string `json:"id"`
		Message string `json:"message"`
		URL     string `json:"URL"`
		Author  User   `json:"author"`
	}
}

NoteHook is a gitlab-specific issue comment webhook body

type NoteMR added in v0.5.3

type NoteMR struct {
	ID           int    `json:"iid"`
	Title        string `json:"title"`
	State        string `json:"state"`
	URL          string `json:"url"`
	AuthorID     int    `json:"author_id"`
	SourceBranch string `json:"source_branch"`
	TargetBranch string `json:"target_branch"`
	LastCommit   struct {
		ID string `json:"id"`
	} `json:"last_commit"`
}

NoteMR is a gitlab-specific note hook merge request webhook body

type NoteResponse added in v0.5.3

type NoteResponse struct {
	Body      string   `json:"body"`
	CreatedAt *v1.Time `json:"created_at"`
}

NoteResponse is a note list response

type Project

type Project struct {
	Name   string `json:"path_with_namespace"`
	WebURL string `json:"web_url"`
}

Project is a name/url for the repository

type PushWebhook

type PushWebhook struct {
	Kind     string  `json:"object_kind"`
	Ref      string  `json:"ref"`
	Project  Project `json:"project"`
	UserName string  `json:"user_name"`
	UserID   int     `json:"user_id"`
	Sha      string  `json:"after"`
}

PushWebhook is a gitlab-specific push event webhook body

type RegistrationWebhookBody

type RegistrationWebhookBody struct {
	EnableSSLVerification   bool   `json:"enable_ssl_verification"`
	ConfidentialIssueEvents bool   `json:"confidential_issues_events"`
	ConfidentialNoteEvents  bool   `json:"confidential_note_events"`
	DeploymentEvents        bool   `json:"deployment_events"`
	ID                      string `json:"id"`
	IssueEvents             bool   `json:"issues_events"`
	JobEvents               bool   `json:"job_events"`
	MergeRequestEvents      bool   `json:"merge_requests_events"`
	NoteEvents              bool   `json:"note_events"`
	PipeLineEvents          bool   `json:"pipeline_events"`
	PushEvents              bool   `json:"push_events"`
	TagPushEvents           bool   `json:"tag_push_events"`
	WikiPageEvents          bool   `json:"wiki_page_events"`
	URL                     string `json:"url"`
	Token                   string `json:"token"`
}

RegistrationWebhookBody is a body for requesting webhook registration for the remote git server

type UpdateMergeRequest added in v0.3.0

type UpdateMergeRequest struct {
	AddLabels    string `json:"add_labels"`
	RemoveLabels string `json:"remove_labels"`
}

UpdateMergeRequest is a struct to update a merge request

type User added in v0.1.4

type User struct {
	ID    int    `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

User is a user who triggered merge request event

type UserInfo added in v0.1.4

type UserInfo struct {
	ID          int    `json:"id"`
	UserName    string `json:"username"`
	PublicEmail string `json:"public_email"`
	Email       string `json:"email"`
}

UserInfo is a body of user get API

type UserPermission added in v0.2.0

type UserPermission struct {
	AccessLevel int `json:"access_level"`
}

UserPermission is a user's permission on a repository

type WebhookEntry

type WebhookEntry struct {
	ID  int    `json:"id"`
	URL string `json:"url"`
}

WebhookEntry is a body of list of registered webhooks

Jump to

Keyboard shortcuts

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