Documentation
¶
Index ¶
- Constants
- func ExtractFromPath(str string) (string, string, error)
- func GetKeyTitle(rawurl string) (string, error)
- func GetProjectId(r *Gitlab, c *client.Client, owner, name string) (projectId string, err error)
- func GetUserAvatar(email string) string
- func GetUserEmail(c *client.Client, defaultURL string) (*client.Client, error)
- func Init()
- func IsAdmin(proj *client.Project) bool
- func IsRead(proj *client.Project) bool
- func IsWrite(proj *client.Project) bool
- func NewClient(url, accessToken string, skipVerify bool) *client.Client
- type Gitlab
- func (g *Gitlab) Activate(user *db.User, repo *model.Repo, link string) error
- func (g *Gitlab) AddDeployKey(token string, id int, deployTitle string, deployKey string) (*client.AddDeployKey, error)
- func (g *Gitlab) AddProjectHook(token string, id int, url string, pushEvents bool) (*client.AddProjectHook, error)
- func (g *Gitlab) AllProjectList(u *db.User) ([]*client.SingleSimpleProject, error)
- func (g *Gitlab) Auth(token, secret string) (string, error)
- func (g *Gitlab) BranchList(token string, gid int) ([]*client.SingleBranch, error)
- func (g *Gitlab) CommitList(token string, id int, ref string) ([]client.SingleCommit, error)
- func (g *Gitlab) CurrentUser(u *db.User) (client.User, error)
- func (g *Gitlab) Deactivate(user *db.User, repo *model.Repo, link string) error
- func (g *Gitlab) File(user *db.User, repo *model.Repo, build *model.Build, f string) ([]byte, error)
- func (g *Gitlab) FileRef(u *db.User, r *model.Repo, ref, f string) ([]byte, error)
- func (g *Gitlab) FileRefParse(u *model.User, id, ref, f string) (*client.FileContent, error)
- func (g *Gitlab) FilesParse(user *model.User, id, ref, f string) ([]*client.RepoFile, error)
- func (g *Gitlab) GetBranchAccessList(u *db.User, pid string) error
- func (g *Gitlab) GetMemberOfProject(u *db.User, pid, uid string) (client.User, error)
- func (g *Gitlab) GetProjectAccessList(u *db.User, pid string) (int, error)
- func (g *Gitlab) GetProjectMembersList(u *db.User, pid string) ([]*client.User, error)
- func (g *Gitlab) GetSingleTag(token string, gid int, tag string) (client.SingleTag, error)
- func (g *Gitlab) GetTagList(token string, gid int) ([]client.SingleTag, error)
- func (g *Gitlab) GetUserOfProject(u *db.User, pid, uname string) (client.User, error)
- func (g *Gitlab) Hook(req *http.Request) (*model.Repo, *model.Build, error)
- func (g *Gitlab) Login(res http.ResponseWriter, req *http.Request) (*db.User, error)
- func (g *Gitlab) Netrc(u *db.User, r *model.Repo) (*model.Netrc, error)
- func (g *Gitlab) Oauth2Transport(r *http.Request) *oauth2.Transport
- func (g *Gitlab) ProjectList(page int, perPage int, token string) ([]*client.SingleSimpleProject, error)
- func (g *Gitlab) SingleBranch(token string, id int, branch string) (*client.SingleBranch, error)
- func (g *Gitlab) SingleCommit(token string, id int, sha string) (*client.SingleCommit, error)
- func (g *Gitlab) SingleProject(token string, gid int) (*client.SingleProject, error)
- func (g *Gitlab) Status(u *db.User, repo *model.Repo, b *model.Build, link string) error
- func (g *Gitlab) Teams(u *db.User) ([]*model.Team, error)
- func (g *Gitlab) UserByID(u *db.User, id string) (client.User, error)
- func (g *Gitlab) UserProjectList(u *db.User) ([]*client.SingleProject, error)
- func (g *Gitlab) ValidateBranch(token string, gid int, branch string) (bool, error)
- func (g *Gitlab) ValidateTag(token string, gid int, tagName string) (bool, error)
- type Opts
Constants ¶
const ( StatusPending = "pending" StatusRunning = "running" StatusSuccess = "success" StatusFailure = "failed" StatusCanceled = "canceled" )
StatusPending ...
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 ...
const DefaultScope = "api"
DefaultScope ...
Variables ¶
This section is empty.
Functions ¶
func GetKeyTitle ¶
GetKeyTitle is a helper function that generates a title for the RSA public key based on the username and domain name.
func GetProjectId ¶
GetProjectId ...
func GetUserEmail ¶
GetUserEmail ...
func IsAdmin ¶
IsAdmin is a helper function that returns true if the user has Admin access to the repository.
func IsRead ¶
IsRead is a helper function that returns true if the user has Read-only access to the repository.
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 ¶
New returns a Remote implementation that integrates with Gitlab, an open source Git service. See https://gitlab.com
func (*Gitlab) Activate ¶
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 ¶
AllProjectList ...
func (*Gitlab) BranchList ¶
BranchList ...
func (*Gitlab) CommitList ¶
CommitList ...
func (*Gitlab) CurrentUser ¶
CurrentUser 获得当前登录者 byhexuan
func (*Gitlab) Deactivate ¶
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 ¶
FileRef fetches the file from the GitHub repository and returns its contents.
func (*Gitlab) FileRefParse ¶
FileRef fetches the file from the GitHub repository and returns its contents.
func (*Gitlab) FilesParse ¶
Files fetches a list of files information
func (*Gitlab) GetBranchAccessList ¶
GetBranchAccessList获得当前登录者 by xiaoshen
func (*Gitlab) GetMemberOfProject ¶
GetMemberOfProject获得当前登录者 by hexuan
func (*Gitlab) GetProjectAccessList ¶
GetProjectAccessList获得当前登录者 by xiaoshen
func (*Gitlab) GetProjectMembersList ¶
GetMemberOfProject获得当前登录者 by hexuan
func (*Gitlab) GetSingleTag ¶
GetSingleTag ...
func (*Gitlab) GetTagList ¶
GetTagList ...
func (*Gitlab) GetUserOfProject ¶
GetUserOfProject by hexuan
func (*Gitlab) Hook ¶
ParseHook parses the post-commit hook from the Request body and returns the required data in a standard format.
func (*Gitlab) Netrc ¶
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 (*Gitlab) ProjectList ¶
func (g *Gitlab) ProjectList(page int, perPage int, token string) ([]*client.SingleSimpleProject, error)
ProjectList ...
func (*Gitlab) SingleBranch ¶
SingleBranch ...
func (*Gitlab) SingleCommit ¶
SingleCommit ...
func (*Gitlab) SingleProject ¶
Get single project https://docs.gitlab.com/ce/api/projects.html#get-single-project
func (*Gitlab) Status ¶
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) UserProjectList ¶
UserProjectList ...
func (*Gitlab) ValidateBranch ¶
ValidateBranch ...
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.