本文整理匯總了Golang中k8s/io/contrib/mungegithub/github.Config.GetUser方法的典型用法代碼示例。如果您正苦於以下問題:Golang Config.GetUser方法的具體用法?Golang Config.GetUser怎麽用?Golang Config.GetUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/contrib/mungegithub/github.Config
的用法示例。
在下文中一共展示了Config.GetUser方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: gatherData
func gatherData(cfg *githubhelper.Config) (*reportData, error) {
issues, err := cfg.ListAllIssues(&github.IssueListByRepoOptions{
State: "open",
Sort: "created",
Labels: []string{"kind/flake"},
})
if err != nil {
return nil, err
}
r := reportData{
loginToEmail: map[string]string{},
loginToIssues: map[string][]issueReportData{},
}
for _, issue := range issues {
assignee := "UNASSIGNED"
if issue.Assignee != nil && issue.Assignee.Login != nil {
assignee = *issue.Assignee.Login
if _, ok := r.loginToEmail[assignee]; !ok {
if u, err := cfg.GetUser(assignee); err == nil {
if u.Email != nil {
r.loginToEmail[assignee] = *u.Email
} else {
// Don't keep looking this up
r.loginToEmail[assignee] = ""
}
}
}
}
age := time.Duration(0)
if issue.CreatedAt != nil {
age = time.Now().Sub(*issue.CreatedAt)
}
priority := "??"
priorityLabels := githubhelper.GetLabelsWithPrefix(issue.Labels, "priority/")
if len(priorityLabels) == 1 {
priority = strings.TrimPrefix(priorityLabels[0], "priority/")
}
if priority == "P2" || priority == "P3" {
r.lowPriorityTests++
continue
}
reportData := issueReportData{
priority: priority,
number: *issue.Number,
title: *issue.Title,
age: age,
}
r.loginToIssues[assignee] = append(r.loginToIssues[assignee], reportData)
if priority == "??" {
const unprioritized = "UNPRIORITIZED"
r.loginToIssues[unprioritized] = append(r.loginToIssues[unprioritized], reportData)
}
r.totalTests++
}
return &r, nil
}
示例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
}