gitlab

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusPending  = "pending"
	StatusRunning  = "running"
	StatusSuccess  = "success"
	StatusFailure  = "failed"
	StatusCanceled = "canceled"
)

StatusPending ...

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"
)

DescPending ...

View Source
const DefaultScope = "api"

DefaultScope ...

Variables

This section is empty.

Functions

func ExtractFromPath

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

ExtractFromPath ...

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)

GetProjectId ...

func GetUserAvatar

func GetUserAvatar(email string) string

GetUserAvatar ...

func GetUserEmail

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

GetUserEmail ...

func Init

func Init()

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 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
}

Gitlab ...

var IGitlab *Gitlab

func New

func New(opts Opts) (*Gitlab, error)

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

func (*Gitlab) Activate

func (g *Gitlab) Activate(user *db.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) AddDeployKey

func (g *Gitlab) AddDeployKey(token string, id int, deployTitle string, deployKey string) (*client.AddDeployKey, error)

AddDeployKey ...

func (*Gitlab) AddProjectHook

func (g *Gitlab) AddProjectHook(token string, id int, url string, pushEvents bool) (*client.AddProjectHook, error)

AddProjectHook ...

func (*Gitlab) AllProjectList

func (g *Gitlab) AllProjectList(u *db.User) ([]*client.SingleSimpleProject, error)

AllProjectList ...

func (*Gitlab) Auth

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

Auth ...

func (*Gitlab) BranchList

func (g *Gitlab) BranchList(token string, gid int) ([]*client.SingleBranch, error)

BranchList ...

func (*Gitlab) CommitList

func (g *Gitlab) CommitList(token string, id int, ref string) ([]client.SingleCommit, error)

CommitList ...

func (*Gitlab) CurrentUser

func (g *Gitlab) CurrentUser(u *db.User) (client.User, error)

CurrentUser 获得当前登录者 byhexuan

func (*Gitlab) Deactivate

func (g *Gitlab) Deactivate(user *db.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

func (g *Gitlab) File(user *db.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

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

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

func (*Gitlab) FileRefParse

func (g *Gitlab) FileRefParse(u *model.User, id, ref, f string) (*client.FileContent, error)

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

func (*Gitlab) FilesParse

func (g *Gitlab) FilesParse(user *model.User, id, ref, f string) ([]*client.RepoFile, error)

Files fetches a list of files information

func (*Gitlab) GetBranchAccessList

func (g *Gitlab) GetBranchAccessList(u *db.User, pid string) error

GetBranchAccessList获得当前登录者 by xiaoshen

func (*Gitlab) GetMemberOfProject

func (g *Gitlab) GetMemberOfProject(u *db.User, pid, uid string) (client.User, error)

GetMemberOfProject获得当前登录者 by hexuan

func (*Gitlab) GetProjectAccessList

func (g *Gitlab) GetProjectAccessList(u *db.User, pid string) (int, error)

GetProjectAccessList获得当前登录者 by xiaoshen

func (*Gitlab) GetProjectMembersList

func (g *Gitlab) GetProjectMembersList(u *db.User, pid string) ([]*client.User, error)

GetMemberOfProject获得当前登录者 by hexuan

func (*Gitlab) GetSingleTag

func (g *Gitlab) GetSingleTag(token string, gid int, tag string) (client.SingleTag, error)

GetSingleTag ...

func (*Gitlab) GetTagList

func (g *Gitlab) GetTagList(token string, gid int) ([]client.SingleTag, error)

GetTagList ...

func (*Gitlab) GetUserOfProject

func (g *Gitlab) GetUserOfProject(u *db.User, pid, uname string) (client.User, error)

GetUserOfProject by hexuan

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) (*db.User, error)

Login authenticates the session and returns the remote user details.

func (*Gitlab) Netrc

func (g *Gitlab) Netrc(u *db.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) ProjectList

func (g *Gitlab) ProjectList(page int, perPage int, token string) ([]*client.SingleSimpleProject, error)

ProjectList ...

func (*Gitlab) SingleBranch

func (g *Gitlab) SingleBranch(token string, id int, branch string) (*client.SingleBranch, error)

SingleBranch ...

func (*Gitlab) SingleCommit

func (g *Gitlab) SingleCommit(token string, id int, sha string) (*client.SingleCommit, error)

SingleCommit ...

func (*Gitlab) SingleProject

func (g *Gitlab) SingleProject(token string, gid int) (*client.SingleProject, error)

Get single project https://docs.gitlab.com/ce/api/projects.html#get-single-project

func (*Gitlab) Status

func (g *Gitlab) Status(u *db.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) Teams

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

Teams ...

func (*Gitlab) UserByID

func (g *Gitlab) UserByID(u *db.User, id string) (client.User, error)

UserByID 由userID获得user信息 by hexuan

func (*Gitlab) UserProjectList

func (g *Gitlab) UserProjectList(u *db.User) ([]*client.SingleProject, error)

UserProjectList ...

func (*Gitlab) ValidateBranch

func (g *Gitlab) ValidateBranch(token string, gid int, branch string) (bool, error)

ValidateBranch ...

func (*Gitlab) ValidateTag

func (g *Gitlab) ValidateTag(token string, gid int, tagName string) (bool, error)

ValidateTag ...

type Opts

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