Merge key fetcher #6
|
@ -27,7 +27,7 @@ func main() {
|
|||
keysDir := parser.String("d", "directory", &argparse.Options{Required: false, Help: "Path where to store the key files", Default: "./"})
|
||||
quiet := parser.Flag("q", "quiet", &argparse.Options{Required: false, Help: "Skip output to stdout", Default: false})
|
||||
ghOrganization := parser.String("o", "org", &argparse.Options{Required: false, Help: "Github Organization name", Default: "OpenFest"})
|
||||
ghTeam := parser.String("t", "team", &argparse.Options{Required: false, Help: "Github Team name", Default: "NOC"})
|
||||
ghTeam := parser.String("t", "team", &argparse.Options{Required: false, Help: "Github Team name, 'all' for all members of the organization", Default: "NOC"})
|
||||
|
||||
// Parse input
|
||||
err := parser.Parse(os.Args)
|
||||
|
@ -107,6 +107,35 @@ func main() {
|
|||
func fetchUsers(client *github.Client, org *string, team *string) (teamMembers []*string) {
|
||||
var targetTeam *github.Team
|
||||
|
||||
if team == nil || *team == "all" {
|
||||
for nextPage := 0; ; {
|
||||
// list all members for the given organization's team
|
||||
opt := &github.ListMembersOptions{
|
||||
PublicOnly: false,
|
||||
ListOptions: github.ListOptions{nextPage, 50},
|
||||
}
|
||||
|
||||
users, rsp, err := client.Organizations.ListMembers(context.Background(), *org, opt)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("client.Organizations.ListMembers ", err)
|
||||
os.Exit(-1)
|
||||
}
|
||||
|
||||
if rsp == nil {
|
||||
fmt.Println("client.Organizations.ListMembers: ", err)
|
||||
}
|
||||
|
||||
for _, user := range users {
|
||||
teamMembers = append(teamMembers, user.Login)
|
||||
}
|
||||
|
||||
if rsp.NextPage == 0 || nextPage == rsp.NextPage {
|
||||
break
|
||||
}
|
||||
nextPage = rsp.NextPage
|
||||
}
|
||||
} else {
|
||||
for nextPage := 0; ; {
|
||||
// list all teams for the specified org
|
||||
opt := &github.ListOptions{nextPage, 50}
|
||||
|
@ -166,6 +195,7 @@ func fetchUsers(client *github.Client, org *string, team *string) (teamMembers [
|
|||
}
|
||||
nextPage = rsp.NextPage
|
||||
}
|
||||
}
|
||||
|
||||
return teamMembers
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue