gitlab

package
Version: v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EventTypeHeader represents the header key for event type of Gitlab.
	EventTypeHeader = "X-Gitlab-Event"

	// NoteHookEvent represents comments event.
	NoteHookEvent = "Note Hook"
	// MergeRequestHookEvent represents merge request event.
	MergeRequestHookEvent = "Merge Request Hook"
	// TagPushHookEvent represents tag push event.
	TagPushHookEvent = "Tag Push Hook"
	// PushHookEvent represents commit push event.
	PushHookEvent = "Push Hook"
)

Variables

This section is empty.

Functions

func NewGitlab

func NewGitlab(scmCfg *v1alpha1.SCMSource) (scm.Provider, error)

NewGitlab news Gitlab v3 or v4 client according to the API version detected from Gitlab server,

func ParseEvent

func ParseEvent(request *http.Request) *scm.EventData

ParseEvent parses data from Gitlab events.

Types

type MergeCommentEvent

type MergeCommentEvent struct {
	ObjectKind string `json:"object_kind"`
	//User       *User  `json:"user"`
	ProjectID int `json:"project_id"`
	Project   struct {
		Name              string `json:"name"`
		Description       string `json:"description"`
		AvatarURL         string `json:"avatar_url"`
		GitSSHURL         string `json:"git_ssh_url"`
		GitHTTPURL        string `json:"git_http_url"`
		Namespace         string `json:"namespace"`
		PathWithNamespace string `json:"path_with_namespace"`
		DefaultBranch     string `json:"default_branch"`
		Homepage          string `json:"homepage"`
		URL               string `json:"url"`
		SSHURL            string `json:"ssh_url"`
		HTTPURL           string `json:"http_url"`
		WebURL            string `json:"web_url"`
	} `json:"project"`
	//Repository       *Repository `json:"repository"`
	ObjectAttributes struct {
		ID         int    `json:"id"`
		Note       string `json:"note"`
		AuthorID   int    `json:"author_id"`
		CreatedAt  string `json:"created_at"`
		UpdatedAt  string `json:"updated_at"`
		ProjectID  int    `json:"project_id"`
		Attachment string `json:"attachment"`
		LineCode   string `json:"line_code"`
		CommitID   string `json:"commit_id"`
		System     bool   `json:"system"`
		//StDiff       *Diff  `json:"st_diff"`
		URL string `json:"url"`
	} `json:"object_attributes"`
	MergeRequest *MergeRequest `json:"merge_request"`
}

MergeCommentEvent ...

type MergeRequest

type MergeRequest struct {
	ID             int    `json:"id"`
	IID            int    `json:"iid"`
	ProjectID      int    `json:"project_id"`
	Title          string `json:"title"`
	Description    string `json:"description"`
	WorkInProgress bool   `json:"work_in_progress"`
	State          string `json:"state"`
	//CreatedAt      *time.Time `json:"created_at"`
	//UpdatedAt      *time.Time `json:"updated_at"`
	CreatedAt    string `json:"created_at"`
	UpdatedAt    string `json:"updated_at"`
	TargetBranch string `json:"target_branch"`
	SourceBranch string `json:"source_branch"`
	Upvotes      int    `json:"upvotes"`
	Downvotes    int    `json:"downvotes"`
	Author       struct {
		Name      string `json:"name"`
		Username  string `json:"username"`
		ID        int    `json:"id"`
		State     string `json:"state"`
		AvatarURL string `json:"avatar_url"`
	} `json:"author"`
	Assignee struct {
		Name      string `json:"name"`
		Username  string `json:"username"`
		ID        int    `json:"id"`
		State     string `json:"state"`
		AvatarURL string `json:"avatar_url"`
	} `json:"assignee"`
	SourceProjectID int      `json:"source_project_id"`
	TargetProjectID int      `json:"target_project_id"`
	Labels          []string `json:"labels"`
	Milestone       struct {
		ID          int    `json:"id"`
		Iid         int    `json:"iid"`
		ProjectID   int    `json:"project_id"`
		Title       string `json:"title"`
		Description string `json:"description"`
		State       string `json:"state"`
		//CreatedAt   *time.Time `json:"created_at"`
		//UpdatedAt   *time.Time `json:"updated_at"`
		CreatedAt string `json:"created_at"`
		UpdatedAt string `json:"updated_at"`
		DueDate   string `json:"due_date"`
	} `json:"milestone"`
	MergeWhenBuildSucceeds   bool   `json:"merge_when_build_succeeds"`
	MergeStatus              string `json:"merge_status"`
	Subscribed               bool   `json:"subscribed"`
	UserNotesCount           int    `json:"user_notes_count"`
	ShouldRemoveSourceBranch bool   `json:"should_remove_source_branch"`
	ForceRemoveSourceBranch  bool   `json:"force_remove_source_branch"`
	Changes                  []struct {
		OldPath     string `json:"old_path"`
		NewPath     string `json:"new_path"`
		AMode       string `json:"a_mode"`
		BMode       string `json:"b_mode"`
		Diff        string `json:"diff"`
		NewFile     bool   `json:"new_file"`
		RenamedFile bool   `json:"renamed_file"`
		DeletedFile bool   `json:"deleted_file"`
	} `json:"changes"`
	WebURL     string `json:"web_url"`
	LastCommit struct {
		ID      string `json:"id"`
		Message string `json:"message"`
	} `json:"last_commit"`
}

MergeRequest ...

type V3

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

V3 represents the SCM provider of API V3 GitLab.

func (*V3) CheckToken

func (g *V3) CheckToken() error

CheckToken checks whether the token has the authority of repo by trying ListRepos with the token.

func (*V3) CreateStatus added in v0.9.6

func (g *V3) CreateStatus(status c_v1alpha1.StatusPhase, targetURL, repo, commitSha string) error

CreateStatus generate a new status for repository.

func (*V3) CreateWebhook

func (g *V3) CreateWebhook(repo string, webhook *scm.Webhook) error

CreateWebhook creates webhook for specified repo.

func (*V3) DeleteWebhook

func (g *V3) DeleteWebhook(repo string, webhookURL string) error

DeleteWebhook deletes webhook from specified repo.

func (*V3) GetPullRequestSHA added in v0.9.6

func (g *V3) GetPullRequestSHA(repo string, number int) (string, error)

GetPullRequestSHA gets latest commit SHA of pull request.

func (*V3) GetToken

func (g *V3) GetToken() (string, error)

GetToken gets the token by the username and password of SCM config.

func (*V3) GetWebhook added in v0.9.6

func (g *V3) GetWebhook(repo string, webhookURL string) (*v3.ProjectHook, error)

GetWebhook gets webhook from specified repo.

func (*V3) ListBranches

func (g *V3) ListBranches(repo string) ([]string, error)

ListBranches lists the branches for specified repo. Only return first 20 branches, will not support listing all branches as v3 api has been deprecated.

func (*V3) ListDockerfiles

func (g *V3) ListDockerfiles(repo string) ([]string, error)

ListDockerfiles lists the Dockerfiles for specified repo.

func (*V3) ListPullRequests added in v0.9.7

func (g *V3) ListPullRequests(repo, state string) ([]scm.PullRequest, error)

ListPullRequests lists the merge requests for specified repo.

func (*V3) ListRepos

func (g *V3) ListRepos() ([]scm.Repository, error)

ListRepos lists the repos by the SCM config.

func (*V3) ListTags

func (g *V3) ListTags(repo string) ([]string, error)

ListTags lists the tags for specified repo. Only return first 20 tags, will not support listing all tags as v3 api has been deprecated.

type V4

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

V4 represents the SCM provider of API V4 GitLab.

func (*V4) CheckToken

func (g *V4) CheckToken() error

CheckToken checks whether the token has the authority of repo by trying ListRepos with the token.

func (*V4) CreateStatus added in v0.9.6

func (g *V4) CreateStatus(status c_v1alpha1.StatusPhase, targetURL, repo, commitSha string) error

CreateStatus generate a new status for repository.

func (*V4) CreateWebhook

func (g *V4) CreateWebhook(repo string, webhook *scm.Webhook) error

CreateWebhook creates webhook for specified repo.

func (*V4) DeleteWebhook

func (g *V4) DeleteWebhook(repo string, webhookURL string) error

DeleteWebhook deletes webhook from specified repo.

func (*V4) GetPullRequestSHA added in v0.9.6

func (g *V4) GetPullRequestSHA(repo string, number int) (string, error)

GetPullRequestSHA gets latest commit SHA of pull request.

func (*V4) GetToken

func (g *V4) GetToken() (string, error)

GetToken gets the token by the username and password of SCM config.

func (*V4) GetWebhook added in v0.9.6

func (g *V4) GetWebhook(repo string, webhookURL string) (*v4.ProjectHook, error)

GetWebhook gets webhook from specified repo.

func (*V4) ListBranches

func (g *V4) ListBranches(repo string) ([]string, error)

ListBranches lists the branches for specified repo.

func (*V4) ListDockerfiles

func (g *V4) ListDockerfiles(repo string) ([]string, error)

ListDockerfiles lists the Dockerfiles for specified repo.

func (*V4) ListPullRequests added in v0.9.7

func (g *V4) ListPullRequests(repo, state string) ([]scm.PullRequest, error)

ListPullRequests lists the merge requests for specified repo.

func (*V4) ListRepos

func (g *V4) ListRepos() ([]scm.Repository, error)

ListRepos lists the repos by the SCM config.

func (*V4) ListTags

func (g *V4) ListTags(repo string) ([]string, error)

ListTags lists the tags for specified repo.

Jump to

Keyboard shortcuts

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