Merge key fetcher #6

Merged
zeridon merged 15 commits from master into master 2019-07-29 14:19:52 +03:00
1 changed files with 11 additions and 9 deletions
Showing only changes of commit 73639ad0fd - Show all commits

View File

@ -64,12 +64,12 @@ func main() {
teams, rsp, err := client.Teams.ListTeams(ctx, *ghOrganization, opt) teams, rsp, err := client.Teams.ListTeams(ctx, *ghOrganization, opt)
if err != nil { if err != nil {
fmt.Errorf("client.ListTeams error: %v", err) fmt.Println("client.ListTeams error: %v", err)
os.Exit(-1) os.Exit(-1)
} }
if rsp == nil { if rsp == nil {
fmt.Errorf("client.Repositories.List returned empty response: %v", err) fmt.Println("client.Repositories.List returned empty response: %v", err)
} }
for _, team := range teams { for _, team := range teams {
@ -86,7 +86,7 @@ func main() {
} }
if nocTeam == nil { if nocTeam == nil {
fmt.Errorf("NOC team not found in OpenFest") fmt.Println("NOC team not found in OpenFest")
os.Exit(2) os.Exit(2)
} }
@ -100,12 +100,12 @@ func main() {
users, rsp, err := client.Teams.ListTeamMembers(context.Background(), *nocTeam.ID, opt) users, rsp, err := client.Teams.ListTeamMembers(context.Background(), *nocTeam.ID, opt)
if err != nil { if err != nil {
fmt.Errorf("client.Teams.ListTeamMembers %v", err) fmt.Println("client.Teams.ListTeamMembers %v", err)
os.Exit(-1) os.Exit(-1)
} }
if rsp == nil { if rsp == nil {
fmt.Errorf("client.Teams.ListTeamMembers: %v", err) fmt.Println("client.Teams.ListTeamMembers: %v", err)
} }
for _, user := range users { for _, user := range users {
@ -131,12 +131,12 @@ func main() {
keys, rsp, err := client.Users.ListKeys(ctx, *user, opt) keys, rsp, err := client.Users.ListKeys(ctx, *user, opt)
if err != nil { if err != nil {
fmt.Errorf("client.Users.ListKeys error: %v", err) fmt.Println("client.Users.ListKeys error: %v", err)
os.Exit(-1) os.Exit(-1)
} }
if rsp == nil { if rsp == nil {
fmt.Errorf("Users.ListKeyss returned empty response: %v", err) fmt.Println("Users.ListKeyss returned empty response: %v", err)
} }
for _, key := range keys { for _, key := range keys {
@ -153,10 +153,12 @@ func main() {
nextPage = rsp.NextPage nextPage = rsp.NextPage
} }
fmt.Println("Writing to", *keysDir + *user+".key") if *quiet == false {
fmt.Println("Writing to", *keysDir + "/" + *user+".key")
}
err := ioutil.WriteFile(*keysDir + "/" + *user+".key", sshKeys.Bytes(), 0444) err := ioutil.WriteFile(*keysDir + "/" + *user+".key", sshKeys.Bytes(), 0444)
if err != nil { if err != nil {
fmt.Errorf(*user+".key error %v", err) fmt.Println(*user+".key error %v", err)
} }
} }