gitlab

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusPending  = "pending"
	StatusRunning  = "running"
	StatusSuccess  = "success"
	StatusFailure  = "failed"
	StatusCanceled = "canceled"
)
View Source
const (
	DescPending  = "the build is pending"
	DescRunning  = "the buils is running"
	DescSuccess  = "the build was successful"
	DescFailure  = "the build failed"
	DescCanceled = "the build canceled"
	DescBlocked  = "the build is pending approval"
	DescDeclined = "the build was rejected"
)
View Source
const DefaultScope = "api"

Variables

This section is empty.

Functions

func ExtractFromPath added in v0.4.2

func ExtractFromPath(str string) (string, string, error)

func GetKeyTitle

func GetKeyTitle(rawurl string) (string, error)

GetKeyTitle is a helper function that generates a title for the RSA public key based on the username and domain name.

func GetProjectId

func GetProjectId(r *Gitlab, c *client.Client, owner, name string) (projectId string, err error)

func GetUserAvatar added in v0.4.2

func GetUserAvatar(email string) string

func GetUserEmail

func GetUserEmail(c *client.Client, defaultURL string) (*client.Client, error)

func IsAdmin

func IsAdmin(proj *client.Project) bool

IsAdmin is a helper function that returns true if the user has Admin access to the repository.

func IsRead

func IsRead(proj *client.Project) bool

IsRead is a helper function that returns true if the user has Read-only access to the repository.

func IsWrite

func IsWrite(proj *client.Project) bool

IsWrite is a helper function that returns true if the user has Read-Write access to the repository.

func New added in v0.5.0

func New(opts Opts) (remote.Remote, error)

New returns a Remote implementation that integrates with Gitlab, an open source Git service. See https://gitlab.com

func NewClient

func NewClient(url, accessToken string, skipVerify bool) *client.Client

NewClient is a helper function that returns a new GitHub client using the provided OAuth token.

Types

type Gitlab

type Gitlab struct {
	URL          string
	Client       string
	Secret       string
	Machine      string
	Username     string
	Password     string
	PrivateMode  bool
	SkipVerify   bool
	HideArchives bool
	Search       bool
}

func Load

func Load(config string) *Gitlab

func (*Gitlab) Activate

func (g *Gitlab) Activate(user *model.User, repo *model.Repo, link string) error

Activate activates a repository by adding a Post-commit hook and a Public Deploy key, if applicable.

func (*Gitlab) Auth

func (g *Gitlab) Auth(token, secret string) (string, error)

func (*Gitlab) Deactivate

func (g *Gitlab) Deactivate(user *model.User, repo *model.Repo, link string) error

Deactivate removes a repository by removing all the post-commit hooks which are equal to link and removing the SSH deploy key.

func (*Gitlab) File added in v0.4.2

func (g *Gitlab) File(user *model.User, repo *model.Repo, build *model.Build, f string) ([]byte, error)

File fetches a file from the remote repository and returns in string format.

func (*Gitlab) FileRef added in v0.6.0

func (g *Gitlab) FileRef(u *model.User, r *model.Repo, ref, f string) ([]byte, error)

FileRef fetches the file from the GitHub repository and returns its contents.

func (*Gitlab) Hook

func (g *Gitlab) Hook(req *http.Request) (*model.Repo, *model.Build, error)

ParseHook parses the post-commit hook from the Request body and returns the required data in a standard format.

func (*Gitlab) Login

func (g *Gitlab) Login(res http.ResponseWriter, req *http.Request) (*model.User, error)

Login authenticates the session and returns the remote user details.

func (*Gitlab) Netrc

func (g *Gitlab) Netrc(u *model.User, r *model.Repo) (*model.Netrc, error)

Netrc returns a netrc file capable of authenticating Gitlab requests and cloning Gitlab repositories. The netrc will use the global machine account when configured.

func (*Gitlab) Oauth2Transport

func (g *Gitlab) Oauth2Transport(r *http.Request) *oauth2.Transport

¯\_(ツ)_/¯

func (*Gitlab) Perm

func (g *Gitlab) Perm(u *model.User, owner, name string) (*model.Perm, error)

Perm fetches the named repository from the remote system.

func (*Gitlab) Repo

func (g *Gitlab) Repo(u *model.User, owner, name string) (*model.Repo, error)

Repo fetches the named repository from the remote system.

func (*Gitlab) Repos

func (g *Gitlab) Repos(u *model.User) ([]*model.RepoLite, error)

Repos fetches a list of repos from the remote system.

func (*Gitlab) Status

func (g *Gitlab) Status(u *model.User, repo *model.Repo, b *model.Build, link string) error

NOTE Currently gitlab doesn't support status for commits and events,

also if we want get MR status in gitlab we need implement a special plugin for gitlab,
gitlab uses API to fetch build status on client side. But for now we skip this.

func (*Gitlab) TeamPerm added in v0.5.0

func (g *Gitlab) TeamPerm(u *model.User, org string) (*model.Perm, error)

TeamPerm is not supported by the Gitlab driver.

func (*Gitlab) Teams added in v0.5.0

func (g *Gitlab) Teams(u *model.User) ([]*model.Team, error)

type Opts added in v0.5.0

type Opts struct {
	URL         string // Gogs server url.
	Client      string // Oauth2 client id.
	Secret      string // Oauth2 client secret.
	Username    string // Optional machine account username.
	Password    string // Optional machine account password.
	PrivateMode bool   // Gogs is running in private mode.
	SkipVerify  bool   // Skip ssl verification.
}

Opts defines configuration options.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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