gitlab

package
v0.0.0-...-6cdb919 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommitAction

type CommitAction struct {
	Action       FileAction
	FilePath     string
	Content      string
	PreviousPath string
}

CommitAction represents a single file action within a commit.

type FileAction

type FileAction string
const (
	FileCreate FileAction = "create"
	FileUpdate FileAction = "update"
	FileDelete FileAction = "delete"
	FileMove   FileAction = "move"
)

The available file actions.

type Interface

type Interface interface {
	// GetGroup gets a group's detail with the given gid.
	// The gid can be the group's ID or relative path such as first/second/third.
	// See https://docs.gitlab.com/ee/api/groups.html#details-of-a-group for more information.
	GetGroup(ctx context.Context, gid interface{}) (*gitlab.Group, error)

	// ListGroupProjects list a group's project
	ListGroupProjects(ctx context.Context, gid interface{}, page, perPage int) ([]*gitlab.Project, error)

	// CreateGroup create a gitlab group with the given name and path.
	// The parentID is alternative, if you specify the parentID, it will
	// create a subgroup of this parent.
	// See https://docs.gitlab.com/ee/api/groups.html#new-group for more information.
	CreateGroup(ctx context.Context, name, path string, parentID *int, visibility string) (*gitlab.Group, error)

	// DeleteGroup delete a gitlab group with the given gid.
	// The gid can be the group's ID or relative path such as first/second/third.
	// See https://docs.gitlab.com/ee/api/groups.html#remove-group for more information.
	DeleteGroup(ctx context.Context, gid interface{}) error

	// GetProject get a project with the specified pid.
	// The pid can be the project's ID or relative path such as fist/second.
	// See https://docs.gitlab.com/ee/api/projects.html#get-single-project for more information.
	GetProject(ctx context.Context, pid interface{}) (*gitlab.Project, error)

	// CreateProject create a project under the specified group.
	// See https://docs.gitlab.com/ee/api/projects.html#create-project for more information.
	CreateProject(ctx context.Context, name string, groupID int, visibility string) (*gitlab.Project, error)

	// DeleteProject delete a project with the given pid.
	// The pid can be the project's ID or relative path such as fist/second.
	// See https://docs.gitlab.com/ee/api/projects.html#delete-project for more information.
	DeleteProject(ctx context.Context, pid interface{}) error

	// GetCommit get a specified commit
	// The pid can be the project's ID or relative path such as fist/second.
	// See https://docs.gitlab.com/ee/api/commits.html#get-a-single-commit for more information.
	GetCommit(ctx context.Context, pid interface{}, commit string) (_ *gitlab.Commit, err error)

	// GetBranch get branch of the specified project.
	// The pid can be the project's ID or relative path such as fist/second.
	// See https://docs.gitlab.com/ee/api/branches.html#get-single-repository-branch for more information.
	GetBranch(ctx context.Context, pid interface{}, branch string) (*gitlab.Branch, error)

	// GetTag get tag of the specified project.
	// The pid can be the project's ID or relative path such as fist/second.
	// see https://docs.gitlab.com/ee/api/tags.html#get-a-single-repository-tag for more information
	GetTag(ctx context.Context, pid interface{}, tag string) (_ *gitlab.Tag, err error)

	// CreateBranch create a branch from fromRef for the specified project.
	// The pid can be the project's ID or relative path such as fist/second.
	// The fromRef can be the name of branch, tag or commit.
	// See https://docs.gitlab.com/ee/api/branches.html#create-repository-branch for more information.
	CreateBranch(ctx context.Context, pid interface{}, branch, fromRef string) (*gitlab.Branch, error)

	// DeleteBranch delete a branch for the specified project.
	// The pid can be the project's ID or relative path such as fist/second.
	// See https://docs.gitlab.com/ee/api/branches.html#delete-repository-branch for more information.
	DeleteBranch(ctx context.Context, pid interface{}, branch string) error

	// ListBranch list the branch, Get a list of repository branches from a project, sorted by name alphabetically.
	// see https://docs.gitlab.com/ee/api/branches.html#list-repository-branches
	ListBranch(ctx context.Context, pid interface{},
		listBranchOptions *gitlab.ListBranchesOptions) (_ []*gitlab.Branch, err error)

	// ListTag list the tag, Get a list of repository tag from a project, sorted by name alphabetically.
	// see https://docs.gitlab.com/ee/api/tags.html#list-project-repository-tags for more information
	ListTag(ctx context.Context, pid interface{},
		listTagOptions *gitlab.ListTagsOptions) (_ []*gitlab.Tag, err error)

	// CreateMR create a merge request from source to target with the specified title in project.
	// The pid can be the project's ID or relative path such as fist/second.
	// See https://docs.gitlab.com/ee/api/merge_requests.html#create-mr for more information.
	CreateMR(ctx context.Context, pid interface{}, source, target, title string) (*gitlab.MergeRequest, error)

	// ListMRs list merge requests for specified project.
	// The pid should be the project's ID.
	// See https://docs.gitlab.com/ee/api/merge_requests.html#list-project-merge-requests for more information.
	ListMRs(ctx context.Context, pid interface{}, source, target, state string) ([]*gitlab.MergeRequest, error)

	// AcceptMR merge a merge request for specified project.
	// The pid can be the project's ID or relative path such as fist/second.
	// See https://docs.gitlab.com/ee/api/merge_requests.html#accept-mr for more information.
	AcceptMR(ctx context.Context, pid interface{}, mrID int,
		mergeCommitMsg *string, shouldRemoveSourceBranch *bool) (*gitlab.MergeRequest, error)

	// CloseMR merge a merge request for specified project.
	// The pid can be the project's ID or relative path such as fist/second.
	// See https://docs.gitlab.com/ee/api/merge_requests.html#update-mr for more information.
	CloseMR(ctx context.Context, pid interface{}, mrID int) (mr *gitlab.MergeRequest, err error)

	// WriteFiles write including create, delete, update multiple files within a specified project.
	// The pid can be the project's ID or relative path such as fist/second.
	// See https://docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions
	// for more information.
	WriteFiles(ctx context.Context, pid interface{}, branch, commitMsg string,
		startBranch *string, actions []CommitAction) (*gitlab.Commit, error)

	// GetFile get a file content for specified filepath in the specified project with the ref.
	// The pid can be the project's ID or relative path such as fist/second.
	// The ref can be the name of branch, tag or commit.
	// See https://docs.gitlab.com/ee/api/repository_files.html#get-file-from-repository for more information.
	GetFile(ctx context.Context, pid interface{}, ref, filepath string) ([]byte, error)

	// TransferProject transfer a project with the specified pid to the new group with the gid.
	// The pid can be the project's ID or relative path such as fist/second.
	// The gid can be the group's ID or relative path such as first/third.
	TransferProject(ctx context.Context, pid interface{}, gid interface{}) error

	// EditNameAndPathForProject update name and path for a specified project.
	// The pid can be the project's ID or relative path such as fist/second.
	EditNameAndPathForProject(ctx context.Context, pid interface{}, newName, newPath *string) error

	// Compare branches, tags or commits.
	// The pid can be the project's ID or relative path such as fist/second.
	// See https://docs.gitlab.com/ee/api/repositories.html#compare-branches-tags-or-commits for more information.
	Compare(ctx context.Context, pid interface{}, from, to string, straight *bool) (*gitlab.Compare, error)

	// GetRepositoryArchive gets an archive of the repository.
	// GitLab API docs: https://docs.gitlab.com/ce/api/repositories.html#get-file-archive
	GetRepositoryArchive(ctx context.Context, pid interface{}, sha string) ([]byte, error)

	GetHTTPURL(ctx context.Context) string

	GetCreatedGroup(ctx context.Context, parentID int, parentPath string,
		name string, visibility string) (*gitlab.Group, error)
}

Interface to interact with gitlab nolint

func New

func New(token, httpURL string) (Interface, error)

New an instance of Gitlab

Jump to

Keyboard shortcuts

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