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


Golang Config.UsersWithAccess方法代碼示例

本文整理匯總了Golang中k8s/io/contrib/mungegithub/github.Config.UsersWithAccess方法的典型用法代碼示例。如果您正苦於以下問題:Golang Config.UsersWithAccess方法的具體用法?Golang Config.UsersWithAccess怎麽用?Golang Config.UsersWithAccess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在k8s/io/contrib/mungegithub/github.Config的用法示例。


在下文中一共展示了Config.UsersWithAccess方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: doGenCommitters

func (sq *SubmitQueue) doGenCommitters(config *github_util.Config) error {
	pushUsers, pullUsers, err := config.UsersWithAccess()
	if err != nil {
		glog.Fatalf("Unable to read committers from github: %v", err)
	}

	pushSet := sets.NewString()
	for _, user := range pushUsers {
		pushSet.Insert(*user.Login)
	}
	pullSet := sets.NewString()
	for _, user := range pullUsers {
		pullSet.Insert(*user.Login)
	}

	if err = writeWhitelist(sq.Committers, "# auto-generated by "+os.Args[0]+" gen-committers; manual additions should go in the whitelist", pushSet); err != nil {
		glog.Fatalf("Unable to write committers: %v", err)
	}
	glog.Info("Successfully updated committers file.")

	existingWhitelist, err := loadWhitelist(sq.Whitelist)
	if err != nil {
		glog.Fatalf("error loading whitelist; it will not be updated: %v", err)
	}

	neededInWhitelist := existingWhitelist.Union(pullSet)
	neededInWhitelist = neededInWhitelist.Difference(pushSet)
	if err = writeWhitelist(sq.Whitelist, "# auto-generated by "+os.Args[0]+" gen-committers; manual additions may be added by hand", neededInWhitelist); err != nil {
		glog.Fatalf("Unable to write additional user whitelist: %v", err)
	}
	glog.Info("Successfully update whitelist file.")
	return nil
}
開發者ID:jojimt,項目名稱:contrib,代碼行數:33,代碼來源:user-lists.go

示例2: RefreshWhitelist

// RefreshWhitelist updates the whitelist, re-getting the list of committers.
func (sq *SubmitQueue) RefreshWhitelist(config *github_util.Config) {
	info := map[string]userInfo{}
	if sq.additionalUserWhitelist == nil {
		users, err := loadWhitelist(sq.Whitelist)
		if err != nil {
			glog.Fatalf("error loading user whitelist: %v", err)
		}
		sq.additionalUserWhitelist = &users
	}

	if sq.committerList == nil {
		committerList, err := loadWhitelist(sq.Committers)
		if err != nil {
			glog.Fatalf("error loading committers whitelist: %v", err)
		}
		sq.committerList = &committerList
	}

	// We must use the values on disk in case it has users which don't have
	// explicit "pull" permission in the API
	allUsers := sets.NewString(sq.additionalUserWhitelist.List()...)

	pushUsers, pullUsers, err := config.UsersWithAccess()
	if err != nil {
		glog.Info("Falling back to static committers list.")
		allUsers = allUsers.Union(*sq.committerList)
		sq.userWhitelist = &allUsers
		return
	}
	for _, user := range pullUsers {
		allUsers.Insert(*user.Login)
		info[*user.Login] = userInfo{
			Access:    "pull access",
			AvatarURL: *user.AvatarURL,
		}
	}
	for _, user := range pushUsers {
		allUsers.Insert(*user.Login)
		info[*user.Login] = userInfo{
			Access:    "push access",
			AvatarURL: *user.AvatarURL,
		}
	}

	// Anyone we got from a config file and not from the API we need to look up info
	for _, login := range allUsers.List() {
		if _, ok := info[login]; ok {
			continue
		}
		user, err := config.GetUser(login)
		if err != nil {
			glog.Errorf("Unable to get user information about %q", login)
			continue
		}
		info[login] = userInfo{
			Access:    "explicitly whitelisted",
			AvatarURL: *user.AvatarURL,
		}
	}
	sq.userWhitelist = &allUsers
	sq.userInfo = info
	return
}
開發者ID:rwehner,項目名稱:contrib,代碼行數:64,代碼來源:user-lists.go


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