本文整理匯總了Golang中github.com/drone/drone/shared/model.Repo.Role方法的典型用法代碼示例。如果您正苦於以下問題:Golang Repo.Role方法的具體用法?Golang Repo.Role怎麽用?Golang Repo.Role使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/drone/drone/shared/model.Repo
的用法示例。
在下文中一共展示了Repo.Role方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetRepos
// GetRepos fetches all repositories that the specified
// user has access to in the remote system.
func (r *Gitlab) GetRepos(user *model.User) ([]*model.Repo, error) {
var repos []*model.Repo
var client = NewClient(r.url, user.Access, r.SkipVerify)
var list, err = client.AllProjects()
if err != nil {
return nil, err
}
var remote = r.GetKind()
var hostname = r.GetHost()
for _, item := range list {
var repo = model.Repo{
UserID: user.ID,
Remote: remote,
Host: hostname,
Owner: item.Namespace.Path,
Name: item.Path,
Private: !item.Public,
CloneURL: item.HttpRepoUrl,
GitURL: item.HttpRepoUrl,
SSHURL: item.SshRepoUrl,
URL: item.Url,
Role: &model.Perm{},
}
if repo.Private {
repo.CloneURL = repo.SSHURL
}
// if the user is the owner we can assume full access,
// otherwise check for the permission items.
if repo.Owner == user.Login {
repo.Role = new(model.Perm)
repo.Role.Admin = true
repo.Role.Write = true
repo.Role.Read = true
} else {
// Fetch current project
project, err := client.Project(strconv.Itoa(item.Id))
if err != nil || project.Permissions == nil {
continue
}
repo.Role.Admin = IsAdmin(project)
repo.Role.Write = IsWrite(project)
repo.Role.Read = IsRead(project)
}
repos = append(repos, &repo)
}
return repos, err
}