@@ -298,47 +298,47 @@ func printAppList(cCtx *cli.Context, apps []types.AppResponse, format string) {
298298 case FORMAT_JSON :
299299 enc := json .NewEncoder (cCtx .App .Writer )
300300 enc .SetIndent ("" , " " )
301- enc .Encode (apps )
301+ enc .Encode (apps ) //nolint:errcheck
302302 case FORMAT_JSONL :
303303 enc := json .NewEncoder (cCtx .App .Writer )
304304 for _ , app := range apps {
305- enc .Encode (app )
305+ enc .Encode (app ) //nolint:errcheck
306306 }
307307 case FORMAT_JSONL_PRETTY :
308308 enc := json .NewEncoder (cCtx .App .Writer )
309309 enc .SetIndent ("" , " " )
310310 for _ , app := range apps {
311- enc .Encode (app )
312- fmt . Fprintf (cCtx . App . Writer , "\n " )
311+ enc .Encode (app ) //nolint:errcheck
312+ printStdout (cCtx , "\n " )
313313 }
314314 case FORMAT_BASIC :
315315 formatStrHead := "%-30s %-5s %4s %-7s %-s\n "
316316 formatStrData := "%-30s %-5s %4d %-7s %-s\n "
317- fmt . Fprintf (cCtx . App . Writer , formatStrHead , "Name" , "Type" , "Ver" , "Auth" , "AppPath" )
317+ printStdout (cCtx , formatStrHead , "Name" , "Type" , "Ver" , "Auth" , "AppPath" )
318318
319319 for _ , app := range apps {
320- fmt . Fprintf (cCtx . App . Writer , formatStrData , app .Metadata .Name , appType (app ), app .Metadata .VersionMetadata .Version , authType (app ),
321- app .AppEntry . AppPathDomain ())
320+ printStdout (cCtx , formatStrData , app .Metadata .Name , appType (app ), app .Metadata .VersionMetadata .Version , authType (app ),
321+ app .AppPathDomain ())
322322 }
323323 case FORMAT_TABLE :
324324 formatStrHead := "%-30s %-35s %-5s %-7s %-15s %-60s %-40s %-30s %-30s\n "
325325 formatStrData := "%-30s %-35s %-5s %7d %-15s %-60s %-40s %-30s %-30s\n "
326- fmt . Fprintf (cCtx . App . Writer , formatStrHead , "Name" , "Id" , "Type" , "Version" , "Auth" ,
326+ printStdout (cCtx , formatStrHead , "Name" , "Id" , "Type" , "Version" , "Auth" ,
327327 "AppPath" , "SourceUrl" , "Spec" , "GitInfo" )
328328
329329 for _ , app := range apps {
330330 gitInfo := ""
331331 if app .Metadata .VersionMetadata .GitBranch != "" || app .Metadata .VersionMetadata .GitCommit != "" {
332332 gitInfo = fmt .Sprintf ("%s:%.20s" , app .Metadata .VersionMetadata .GitBranch , app .Metadata .VersionMetadata .GitCommit )
333333 }
334- fmt . Fprintf (cCtx . App . Writer , formatStrData , app .Metadata .Name , app .Id , appType (app ), app .Metadata .VersionMetadata .Version , authType (app ),
335- app .AppEntry . AppPathDomain (), app .SourceUrl , app .Metadata .Spec , gitInfo )
334+ printStdout (cCtx , formatStrData , app .Metadata .Name , app .Id , appType (app ), app .Metadata .VersionMetadata .Version , authType (app ),
335+ app .AppPathDomain (), app .SourceUrl , app .Metadata .Spec , gitInfo )
336336 }
337337 case FORMAT_CSV :
338338 for _ , app := range apps {
339- fmt . Fprintf (cCtx . App . Writer , "\" %s\" ,%s,%s,%d,%s,%s,\" %s\" ,\" %s\" , %s, %s, \" %s\" \n " , app .Metadata .Name , app .Id , appType (app ),
339+ printStdout (cCtx , "\" %s\" ,%s,%s,%d,%s,%s,\" %s\" ,\" %s\" , %s, %s, \" %s\" \n " , app .Metadata .Name , app .Id , appType (app ),
340340 app .Metadata .VersionMetadata .Version , authType (app ), app .Metadata .VersionMetadata .GitBranch ,
341- app .AppEntry . AppPathDomain (), app .SourceUrl , app .Metadata .Spec , app .Metadata .VersionMetadata .GitBranch , app .Metadata .VersionMetadata .GitCommit )
341+ app .AppPathDomain (), app .SourceUrl , app .Metadata .Spec , app .Metadata .VersionMetadata .GitBranch , app .Metadata .VersionMetadata .GitCommit )
342342 }
343343 default :
344344 panic (fmt .Errorf ("unknown format %s" , format ))
@@ -366,13 +366,14 @@ func appType(app types.AppResponse) string {
366366}
367367
368368func authType (app types.AppResponse ) string {
369- if app .Settings .AuthnType == types .AppAuthnNone {
369+ switch app .Settings .AuthnType {
370+ case types .AppAuthnNone :
370371 return "NONE"
371- } else if app . Settings . AuthnType == types .AppAuthnSystem {
372+ case types .AppAuthnSystem :
372373 return "SYSTEM"
373- } else if app . Settings . AuthnType == types .AppAuthnDefault || app . Settings . AuthnType == "" {
374+ case types .AppAuthnDefault , "" :
374375 return "DEFAULT"
375- } else {
376+ default :
376377 return string (app .Settings .AuthnType )
377378 }
378379}
@@ -449,9 +450,9 @@ Examples:
449450 }
450451
451452 for _ , appInfo := range deleteResult .AppInfo {
452- fmt . Fprintf (cCtx . App . Writer , "Deleting %s - %s\n " , appInfo .AppPathDomain , appInfo .Id )
453+ printStdout (cCtx , "Deleting %s - %s\n " , appInfo .AppPathDomain , appInfo .Id )
453454 }
454- fmt . Fprintf (cCtx . App . Writer , "%d app(s) deleted.\n " , len (deleteResult .AppInfo ))
455+ printStdout (cCtx , "%d app(s) deleted.\n " , len (deleteResult .AppInfo ))
455456
456457 if deleteResult .DryRun {
457458 fmt .Print (DRY_RUN_MESSAGE )
@@ -512,17 +513,17 @@ func appApproveCommand(commonFlags []cli.Flag, clientConfig *types.ClientConfig)
512513 }
513514
514515 if len (approveResponse .PromoteResults ) > 0 {
515- fmt . Fprintf (cCtx . App . Writer , "Promoted apps: " )
516+ printStdout (cCtx , "Promoted apps: " )
516517 for i , promoteResult := range approveResponse .PromoteResults {
517518 if i > 0 {
518- fmt . Fprintf (cCtx . App . Writer , ", " )
519+ printStdout (cCtx , ", " )
519520 }
520- fmt . Fprintf (cCtx . App . Writer , "%s" , promoteResult )
521+ printStdout (cCtx , "%s" , promoteResult )
521522 }
522- fmt . Fprintln (cCtx . App . Writer )
523+ printStdout (cCtx , " \n " )
523524 }
524525
525- fmt . Fprintf (cCtx . App . Writer , "%d app(s) audited, %d app(s) approved, %d app(s) promoted.\n " ,
526+ printStdout (cCtx , "%d app(s) audited, %d app(s) approved, %d app(s) promoted.\n " ,
526527 len (approveResponse .StagedUpdateResults ), approvedCount , len (approveResponse .PromoteResults ))
527528
528529 if approveResponse .DryRun {
@@ -591,29 +592,29 @@ func appReloadCommand(commonFlags []cli.Flag, clientConfig *types.ClientConfig)
591592 }
592593
593594 if len (reloadResponse .ReloadResults ) > 0 {
594- fmt . Fprintf (cCtx . App . Writer , "Reloaded apps: " )
595+ printStdout (cCtx , "Reloaded apps: " )
595596 for i , reloadResult := range reloadResponse .ReloadResults {
596597 if i > 0 {
597- fmt . Fprintf (cCtx . App . Writer , ", " )
598+ printStdout (cCtx , ", " )
598599 }
599- fmt . Fprintf (cCtx . App . Writer , "%s" , reloadResult )
600+ printStdout (cCtx , "%s" , reloadResult )
600601 }
601- fmt . Fprintln (cCtx . App . Writer )
602+ printStdout (cCtx , " \n " )
602603 }
603604
604605 if len (reloadResponse .SkippedResults ) > 0 {
605- fmt . Fprintf (cCtx . App . Writer , "Skipped apps: " )
606+ printStdout (cCtx , "Skipped apps: " )
606607 for i , skipResult := range reloadResponse .SkippedResults {
607608 if i > 0 {
608- fmt . Fprintf (cCtx . App . Writer , ", " )
609+ printStdout (cCtx , ", " )
609610 }
610- fmt . Fprintf (cCtx . App . Writer , "%s" , skipResult )
611+ printStdout (cCtx , "%s" , skipResult )
611612 }
612- fmt . Fprintln (cCtx . App . Writer )
613+ printStdout (cCtx , " \n " )
613614 }
614615
615616 if len (reloadResponse .ApproveResults ) > 0 {
616- fmt . Fprintf (cCtx . App . Writer , "Approved apps:\n " )
617+ printStdout (cCtx , "Approved apps:\n " )
617618 for _ , approveResult := range reloadResponse .ApproveResults {
618619 if ! approveResult .NeedsApproval {
619620 // Server does not return these for reload to reduce the noise
@@ -626,17 +627,17 @@ func appReloadCommand(commonFlags []cli.Flag, clientConfig *types.ClientConfig)
626627 }
627628
628629 if len (reloadResponse .PromoteResults ) > 0 {
629- fmt . Fprintf (cCtx . App . Writer , "Promoted apps: " )
630+ printStdout (cCtx , "Promoted apps: " )
630631 for i , promoteResult := range reloadResponse .PromoteResults {
631632 if i > 0 {
632- fmt . Fprintf (cCtx . App . Writer , ", " )
633+ printStdout (cCtx , ", " )
633634 }
634- fmt . Fprintf (cCtx . App . Writer , "%s" , promoteResult )
635+ printStdout (cCtx , "%s" , promoteResult )
635636 }
636- fmt . Fprintln (cCtx . App . Writer )
637+ printStdout (cCtx , " \n " )
637638 }
638639
639- fmt . Fprintf (cCtx . App . Writer , "%d app(s) reloaded, %d app(s) skipped, %d app(s) approved, %d app(s) promoted.\n " ,
640+ printStdout (cCtx , "%d app(s) reloaded, %d app(s) skipped, %d app(s) approved, %d app(s) promoted.\n " ,
640641 len (reloadResponse .ReloadResults ), len (reloadResponse .SkippedResults ), len (reloadResponse .ApproveResults ), len (reloadResponse .PromoteResults ))
641642
642643 if reloadResponse .DryRun {
@@ -686,7 +687,7 @@ func appPromoteCommand(commonFlags []cli.Flag, clientConfig *types.ClientConfig)
686687 for _ , approveResult := range promoteResponse .PromoteResults {
687688 fmt .Printf ("Promoting %s\n " , approveResult )
688689 }
689- fmt . Fprintf (cCtx . App . Writer , "%d app(s) promoted.\n " , len (promoteResponse .PromoteResults ))
690+ printStdout (cCtx , "%d app(s) promoted.\n " , len (promoteResponse .PromoteResults ))
690691
691692 if promoteResponse .DryRun {
692693 fmt .Print (DRY_RUN_MESSAGE )
0 commit comments