本文整理匯總了Golang中github.com/drone/drone/model.Perm.Admin方法的典型用法代碼示例。如果您正苦於以下問題:Golang Perm.Admin方法的具體用法?Golang Perm.Admin怎麽用?Golang Perm.Admin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/drone/drone/model.Perm
的用法示例。
在下文中一共展示了Perm.Admin方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Perm
func (c *client) Perm(u *model.User, owner, repo string) (*model.Perm, error) {
// TODO need to fetch real permissions here
perms := new(model.Perm)
perms.Pull = true
perms.Admin = true
perms.Push = true
return perms, nil
}
示例2: FindRepoPerms
func (c *Client) FindRepoPerms(owner string, repo string) (*model.Perm, error) {
perms := new(model.Perm)
// If you don't have access return none right away
_, err := c.FindRepo(owner, repo)
if err != nil {
return perms, err
}
// Must have admin to be able to list hooks. If have access the enable perms
_, err = c.client.Get(fmt.Sprintf(pathHook, c.base, owner, repo, hookName))
if err == nil {
perms.Push = true
perms.Admin = true
}
perms.Pull = true
return perms, nil
}
示例3: Perm
func (c *client) Perm(u *model.User, owner, repo string) (*model.Perm, error) {
client := NewClientWithToken(&c.Consumer, u.Token)
perms := new(model.Perm)
// If you don't have access return none right away
_, err := c.FindRepo(client, owner, repo)
if err != nil {
return perms, err
}
// Must have admin to be able to list hooks. If have access the enable perms
_, err = client.Get(fmt.Sprintf("%s/rest/api/1.0/projects/%s/repos/%s/settings/hooks/%s", c.URL, owner, repo, "com.atlassian.stash.plugin.stash-web-post-receive-hooks-plugin:postReceiveHook"))
if err == nil {
perms.Push = true
perms.Admin = true
}
perms.Pull = true
return perms, nil
}
示例4: Perm
// Perm fetches the named repository permissions from
// the remote system for the specified user.
func (bb *Bitbucket) Perm(u *model.User, owner, name string) (*model.Perm, error) {
token := oauth2.Token{AccessToken: u.Token, RefreshToken: u.Secret}
client := NewClientToken(bb.Client, bb.Secret, &token)
perms := new(model.Perm)
_, err := client.FindRepo(owner, name)
if err != nil {
return perms, err
}
// if we've gotten this far we know that the user at
// least has read access to the repository.
perms.Pull = true
// if the user has access to the repository hooks we
// can deduce that the user has push and admin access.
_, err = client.ListHooks(owner, name, &ListOpts{})
if err == nil {
perms.Push = true
perms.Admin = true
}
return perms, nil
}