當前位置: 首頁>>代碼示例>>Golang>>正文


Golang model.Perm類代碼示例

本文整理匯總了Golang中github.com/drone/drone/model.Perm的典型用法代碼示例。如果您正苦於以下問題:Golang Perm類的具體用法?Golang Perm怎麽用?Golang Perm使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Perm類的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
}
開發者ID:tnaoto,項目名稱:drone,代碼行數:8,代碼來源:bitbucketserver.go

示例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
}
開發者ID:sis-tools,項目名稱:drone,代碼行數:16,代碼來源:client.go

示例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
}
開發者ID:tboerger,項目名稱:drone,代碼行數:19,代碼來源:bitbucketserver.go

示例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
}
開發者ID:fclairamb,項目名稱:drone,代碼行數:26,代碼來源:bitbucket.go


注:本文中的github.com/drone/drone/model.Perm類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。