From 73639ad0fde8068fd8dbc469135263f953873b57 Mon Sep 17 00:00:00 2001 From: Shteryana Shopova Date: Sat, 20 Jul 2019 22:12:35 +0300 Subject: [PATCH] Print errors proper --- access/fetch-keys/main.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/access/fetch-keys/main.go b/access/fetch-keys/main.go index a56b7a6..0ddcadf 100644 --- a/access/fetch-keys/main.go +++ b/access/fetch-keys/main.go @@ -64,12 +64,12 @@ func main() { teams, rsp, err := client.Teams.ListTeams(ctx, *ghOrganization, opt) if err != nil { - fmt.Errorf("client.ListTeams error: %v", err) + fmt.Println("client.ListTeams error: %v", err) os.Exit(-1) } 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 { @@ -86,7 +86,7 @@ func main() { } if nocTeam == nil { - fmt.Errorf("NOC team not found in OpenFest") + fmt.Println("NOC team not found in OpenFest") os.Exit(2) } @@ -100,12 +100,12 @@ func main() { users, rsp, err := client.Teams.ListTeamMembers(context.Background(), *nocTeam.ID, opt) if err != nil { - fmt.Errorf("client.Teams.ListTeamMembers %v", err) + fmt.Println("client.Teams.ListTeamMembers %v", err) os.Exit(-1) } if rsp == nil { - fmt.Errorf("client.Teams.ListTeamMembers: %v", err) + fmt.Println("client.Teams.ListTeamMembers: %v", err) } for _, user := range users { @@ -131,12 +131,12 @@ func main() { keys, rsp, err := client.Users.ListKeys(ctx, *user, opt) if err != nil { - fmt.Errorf("client.Users.ListKeys error: %v", err) + fmt.Println("client.Users.ListKeys error: %v", err) os.Exit(-1) } 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 { @@ -153,10 +153,12 @@ func main() { 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) if err != nil { - fmt.Errorf(*user+".key error %v", err) + fmt.Println(*user+".key error %v", err) } }