gitlab

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const EnvBaseURL = "GITLAB_BASE_URL"

EnvBaseURL is GitLab base URL. This can be set to a domain endpoint to use with Private GitLab.

View Source
const EnvToken = "GITLAB_TOKEN"

EnvToken is GitLab API Token

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	CreateMergeRequestNote(mergeRequest int, opt *gitlab.CreateMergeRequestNoteOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Note, *gitlab.Response, error)
	UpdateMergeRequestNote(mergeRequest, note int, opt *gitlab.UpdateMergeRequestNoteOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Note, *gitlab.Response, error)
	ListMergeRequestNotes(mergeRequest int, opt *gitlab.ListMergeRequestNotesOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Note, *gitlab.Response, error)
	GetMergeRequest(mergeRequest int, opt *gitlab.GetMergeRequestsOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error)
	UpdateMergeRequest(mergeRequest int, opt *gitlab.UpdateMergeRequestOptions, options ...gitlab.RequestOptionFunc) (*gitlab.MergeRequest, *gitlab.Response, error)
	PostCommitComment(sha string, opt *gitlab.PostCommitCommentOptions, options ...gitlab.RequestOptionFunc) (*gitlab.CommitComment, *gitlab.Response, error)
	AddMergeRequestLabels(labels *[]string, mergeRequest int) (gitlab.Labels, error)
	RemoveMergeRequestLabels(labels *[]string, mergeRequest int) (gitlab.Labels, error)
	ListMergeRequestLabels(mergeRequest int, opt *gitlab.GetMergeRequestsOptions, options ...gitlab.RequestOptionFunc) (gitlab.Labels, error)
	GetLabel(labelName string, options ...gitlab.RequestOptionFunc) (*gitlab.Label, *gitlab.Response, error)
	UpdateLabel(opt *gitlab.UpdateLabelOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Label, *gitlab.Response, error)
	GetCommit(sha string, options ...gitlab.RequestOptionFunc) (*gitlab.Commit, *gitlab.Response, error)
	ListMergeRequestsByCommit(sha string, options ...gitlab.RequestOptionFunc) ([]*gitlab.MergeRequest, *gitlab.Response, error)
}

API is GitLab API interface

type Client

type Client struct {
	*gitlab.Client
	Debug  bool
	Config Config

	Comment *CommentService
	Commits *CommitsService
	Notify  *NotifyService

	API API
	// contains filtered or unexported fields
}

Client ...

func NewClient

func NewClient(cfg Config) (*Client, error)

NewClient returns Client initialized with Config

type CommentService

type CommentService service

CommentService handles communication with the comment related methods of GitLab API

func (*CommentService) List

func (g *CommentService) List(number int) ([]*gitlab.Note, error)

List lists comments on GitLab merge requests

func (*CommentService) Patch

func (g *CommentService) Patch(note int, body string, opt PostOptions) error

Patch patches on the specific comment

func (*CommentService) Post

func (g *CommentService) Post(body string, opt PostOptions) error

Post posts comment

type CommitsService

type CommitsService service

CommitsService handles communication with the commits related methods of GitLab API

func (*CommitsService) ListMergeRequestIIDsByRevision added in v0.2.0

func (g *CommitsService) ListMergeRequestIIDsByRevision(revision string) ([]int, error)

type Config

type Config struct {
	Token     string
	BaseURL   string
	NameSpace string
	Project   string
	MR        MergeRequest
	CI        string
	Parser    terraform.Parser
	// Template is used for all Terraform command output
	Template           *terraform.Template
	ParseErrorTemplate *terraform.Template
	// ResultLabels is a set of labels to apply depending on the plan result
	ResultLabels     ResultLabels
	Vars             map[string]string
	EmbeddedVarNames []string
	Templates        map[string]string
	UseRawOutput     bool
	Patch            bool
}

Config is a configuration for GitLab client

type GitLab

type GitLab struct {
	*gitlab.Client
	// contains filtered or unexported fields
}

GitLab represents the attribute information necessary for requesting GitLab API

func (*GitLab) AddMergeRequestLabels

func (g *GitLab) AddMergeRequestLabels(labels *[]string, mergeRequest int) (gitlab.Labels, error)

AddMergeRequestLabels adds labels on the merge request.

func (*GitLab) CreateMergeRequestNote

func (g *GitLab) CreateMergeRequestNote(mergeRequest int, opt *gitlab.CreateMergeRequestNoteOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Note, *gitlab.Response, error)

CreateMergeRequestNote is a wrapper of https://godoc.org/github.com/xanzy/go-gitlab#NotesService.CreateMergeRequestNote

func (*GitLab) GetLabel

func (g *GitLab) GetLabel(labelName string, options ...gitlab.RequestOptionFunc) (*gitlab.Label, *gitlab.Response, error)

GetLabel is a wrapper of https://pkg.go.dev/github.com/xanzy/go-gitlab#LabelsService.GetLabel

func (*GitLab) ListMergeRequestLabels

func (g *GitLab) ListMergeRequestLabels(mergeRequest int, opt *gitlab.GetMergeRequestsOptions, options ...gitlab.RequestOptionFunc) (gitlab.Labels, error)

ListMergeRequestLabels lists labels on the merger request

func (*GitLab) ListMergeRequestNotes

func (g *GitLab) ListMergeRequestNotes(mergeRequest int, opt *gitlab.ListMergeRequestNotesOptions, options ...gitlab.RequestOptionFunc) ([]*gitlab.Note, *gitlab.Response, error)

ListMergeRequestNotes is a wrapper of https://godoc.org/github.com/xanzy/go-gitlab#NotesService.ListMergeRequestNotes

func (*GitLab) ListMergeRequestsByCommit added in v0.2.0

func (g *GitLab) ListMergeRequestsByCommit(sha string, options ...gitlab.RequestOptionFunc) ([]*gitlab.MergeRequest, *gitlab.Response, error)

func (*GitLab) RemoveMergeRequestLabels

func (g *GitLab) RemoveMergeRequestLabels(labels *[]string, mergeRequest int) (gitlab.Labels, error)

RemoveMergeRequestLabels removes labels on the merge request.

func (*GitLab) UpdateMergeRequestNote

func (g *GitLab) UpdateMergeRequestNote(mergeRequest, note int, opt *gitlab.UpdateMergeRequestNoteOptions, options ...gitlab.RequestOptionFunc) (*gitlab.Note, *gitlab.Response, error)

UpdateMergeRequestNote is a wrapper of https://pkg.go.dev/github.com/xanzy/go-gitlab#NotesService.UpdateMergeRequestNote

type MergeRequest

type MergeRequest struct {
	Revision string
	Title    string
	Message  string
	Number   int
}

MergeRequest represents GitLab Merge Request metadata

func (*MergeRequest) IsNumber

func (mr *MergeRequest) IsNumber() bool

IsNumber returns true if MergeRequest is Merge Request build

type NotifyService

type NotifyService service

NotifyService handles communication with the notification related methods of GitLab API

func (*NotifyService) Notify

func (g *NotifyService) Notify(param notifier.ParamExec) (int, error)

Notify posts comment optimized for notifications

type PostOptions

type PostOptions struct {
	Number   int
	Revision string
}

PostOptions specifies the optional parameters to post comments to a pull request

type ResultLabels

type ResultLabels struct {
	AddOrUpdateLabel      string
	DestroyLabel          string
	NoChangesLabel        string
	PlanErrorLabel        string
	AddOrUpdateLabelColor string
	DestroyLabelColor     string
	NoChangesLabelColor   string
	PlanErrorLabelColor   string
}

ResultLabels represents the labels to add to the PR depending on the plan result

func (*ResultLabels) HasAnyLabelDefined

func (r *ResultLabels) HasAnyLabelDefined() bool

HasAnyLabelDefined returns true if any of the internal labels are set

func (*ResultLabels) IsResultLabel

func (r *ResultLabels) IsResultLabel(label string) bool

IsResultLabel returns true if a label matches any of the internal labels

Directories

Path Synopsis
Package gitlabmock is a generated GoMock package.
Package gitlabmock is a generated GoMock package.

Jump to

Keyboard shortcuts

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