gitlab

package
v0.0.0-...-145771a Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const GitLabAPI = "/api/v3/"

Variables

This section is empty.

Functions

func RandomString

func RandomString(strlen int) string

RandomString generates a random string of a specified length.

Types

type Client

type Client struct {
	*gogitlab.Client
	Token string

	Projects *Projects
	Labels   *Labels
}

Client is a wrapper for the go-gitlab.Client object that provides additional methods and initializes with a URL.

func NewClient

func NewClient(uri *url.URL, token string) (*Client, error)

NewClient returns a Client object that can be used to make API calls. If instead of token you have username and password, you should use NewClientForUser().

func NewClientForUser

func NewClientForUser(uri *url.URL, user, pass string) (*Client, error)

NewClientForUser is the same as NewClient but uses an user instead of a private token to authenticate.

type Labels

type Labels struct {
	*gogitlab.LabelsService
	// contains filtered or unexported fields
}

func (*Labels) CopyGlobalLabelsTo

func (srv *Labels) CopyGlobalLabelsTo(pid interface{}) error

CopyGlobalLabelsTo copies the global labels to the given project id. Since there's no API in GitLab for accessing global labels, it creates a temporary project that should have all global labels copied into and then reads the labels from it. It deletes the temporary project when done.

If at least one label fails to copy, it will return an error.

func (*Labels) CopyLabels

func (srv *Labels) CopyLabels(from, to interface{}) error

CopyLabels copies the labels from a project into another one, based on the given pid's.

If at least one label fails to copy, it will return an error.

func (*Labels) DeleteWithRegex

func (srv *Labels) DeleteWithRegex(pid interface{}, pattern string) error

DeleteWithRegex deletes labels from a project, optionally by matching against a Regexp pattern.

func (*Labels) UpdateWithRegex

func (srv *Labels) UpdateWithRegex(pid interface{}, opts *gogitlab.UpdateLabelOptions) error

UpdateWithRegex updates label(s) by a given regex in a given project. The difference between *LabelsService.UpdateLabel() and this is that opts.Name is a regexp string, so you can do things like replace all labels like 'type:bug' with 'type/bug' using:

opts.Name:    "(.+):(.+)"
opts.NewName: "${1}/${2}"

If at least one label fails to update, it will return an error.

type NotFound

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

func (*NotFound) Error

func (e *NotFound) Error() string

type Projects

type Projects struct {
	*gogitlab.ProjectsService
	// contains filtered or unexported fields
}

func (*Projects) ByPath

func (srv *Projects) ByPath(path string) (proj *gogitlab.Project, err error)

ProjectByPath searches and returns a project with the given path. Both project and error can be nil, if no project was found.

func (*Projects) Search

func (srv *Projects) Search(query string, opts *gogitlab.SearchProjectsOptions, stop func(*gogitlab.Project) bool) error

Jump to

Keyboard shortcuts

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