This repository was archived by the owner on Mar 1, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -4,10 +4,10 @@ import (
44 "os"
55 "sync"
66 "time"
7- "strings"
87
98 "github.com/sirupsen/logrus"
109 "github.com/urfave/cli"
10+ "google.golang.org/api/googleapi"
1111 gIAM "google.golang.org/api/iam/v1"
1212 "gopkg.in/AlecAivazis/survey.v1"
1313
@@ -187,14 +187,19 @@ listServiceAccountGroupMembers:
187187 logrus .Debugf ("Adding %s to Group" , address )
188188 _ , err := api .AddMember (adminApi , serviceAccountGroupAddress , address )
189189 if err != nil {
190- if strings .Contains (err .Error (),"409: Member already exists., duplicate" ) {
191- logrus .Info ("Account already exists. Skipping." )
192- time .Sleep (100 * time .Millisecond )
193- } else {
194- logrus .Error ("An error occurred when adding an account. Retrying..." , err )
195- time .Sleep (100 * time .Millisecond )
196- goto addMemberToGroup
197- }
190+ if gerr , ok := err .(* googleapi.Error ); ok {
191+ switch gerr .Code {
192+ case 409 :
193+ logrus .Info ("Account already exists. Skipping." )
194+ time .Sleep (100 * time .Millisecond )
195+ default :
196+ logrus .Error ("An error occurred when adding an account. Retrying..." , err )
197+ time .Sleep (100 * time .Millisecond )
198+ goto addMemberToGroup
199+ }
200+ } else {
201+ logrus .Fatal ("An unknown error occurred: " , err )
202+ }
198203 }
199204 }(address )
200205
You can’t perform that action at this time.
0 commit comments