Skip to content

Commit 815c5d5

Browse files
committed
Fix lint errors reported by golangci-lint
1 parent bbfb087 commit 815c5d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+435
-447
lines changed

cmd/openrun/account_cmds.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,20 @@ func accountLinkCommand(commonFlags []cli.Flag, clientConfig *types.ClientConfig
6969
}
7070

7171
if len(linkResponse.PromoteResults) > 0 {
72-
fmt.Fprintf(cCtx.App.Writer, "Promoted apps: ")
72+
printStdout(cCtx, "Promoted apps: ")
7373
for i, promoteResult := range linkResponse.PromoteResults {
7474
if i > 0 {
75-
fmt.Fprintf(cCtx.App.Writer, ", ")
75+
printStdout(cCtx, ", ")
7676
}
77-
fmt.Fprintf(cCtx.App.Writer, "%s", promoteResult)
77+
printStdout(cCtx, "%s", promoteResult)
7878
}
79-
fmt.Fprintln(cCtx.App.Writer)
79+
fmt.Fprintln(cCtx.App.Writer) //nolint:errcheck
8080
}
8181

82-
fmt.Fprintf(cCtx.App.Writer, "%d app(s) linked, %d app(s) promoted.\n", len(linkResponse.StagedUpdateResults), len(linkResponse.PromoteResults))
82+
printStdout(cCtx, "%d app(s) linked, %d app(s) promoted.\n", len(linkResponse.StagedUpdateResults), len(linkResponse.PromoteResults))
8383

8484
if linkResponse.DryRun {
85-
fmt.Print(DRY_RUN_MESSAGE)
85+
fmt.Print(DRY_RUN_MESSAGE) //nolint:errcheck
8686
}
8787

8888
return nil
@@ -125,12 +125,12 @@ func accountListCommand(commonFlags []cli.Flag, clientConfig *types.ClientConfig
125125

126126
appInfo := response.AppEntry
127127
if len(appInfo.Metadata.Accounts) == 0 {
128-
fmt.Fprintf(cCtx.App.Writer, "No account links for app %s : %s\n", appInfo.AppPathDomain(), appInfo.Id)
128+
printStdout(cCtx, "No account links for app %s : %s\n", appInfo.AppPathDomain(), appInfo.Id)
129129
return nil
130130
}
131-
fmt.Fprintf(cCtx.App.Writer, "Account links for app %s : %s\n", appInfo.AppPathDomain(), appInfo.Id)
131+
printStdout(cCtx, "Account links for app %s : %s\n", appInfo.AppPathDomain(), appInfo.Id)
132132
for _, plugin := range appInfo.Metadata.Accounts {
133-
fmt.Fprintf(cCtx.App.Writer, " %s: %s\n", plugin.Plugin, plugin.AccountName)
133+
printStdout(cCtx, " %s: %s\n", plugin.Plugin, plugin.AccountName)
134134
}
135135

136136
return nil
@@ -190,24 +190,24 @@ func updateParamsCommand(commonFlags []cli.Flag, clientConfig *types.ClientConfi
190190
}
191191

192192
for _, app := range updateResponse.StagedUpdateResults {
193-
fmt.Printf("Updated app %s\n", app)
193+
fmt.Printf("Updated app %s\n", app) //nolint:errcheck
194194
}
195195

196196
if len(updateResponse.PromoteResults) > 0 {
197-
fmt.Fprintf(cCtx.App.Writer, "Promoted apps: ")
197+
printStdout(cCtx, "Promoted apps: ")
198198
for i, promoteResult := range updateResponse.PromoteResults {
199199
if i > 0 {
200-
fmt.Fprintf(cCtx.App.Writer, ", ")
200+
printStdout(cCtx, ", ")
201201
}
202-
fmt.Fprintf(cCtx.App.Writer, "%s", promoteResult)
202+
printStdout(cCtx, "%s", promoteResult)
203203
}
204-
fmt.Fprintln(cCtx.App.Writer)
204+
printStdout(cCtx, "\n")
205205
}
206206

207-
fmt.Fprintf(cCtx.App.Writer, "%d app(s) updated, %d app(s) promoted.\n", len(updateResponse.StagedUpdateResults), len(updateResponse.PromoteResults))
207+
printStdout(cCtx, "%d app(s) updated, %d app(s) promoted.\n", len(updateResponse.StagedUpdateResults), len(updateResponse.PromoteResults))
208208

209209
if updateResponse.DryRun {
210-
fmt.Print(DRY_RUN_MESSAGE)
210+
fmt.Print(DRY_RUN_MESSAGE) //nolint:errcheck
211211
}
212212

213213
return nil
@@ -250,12 +250,12 @@ func paramListCommand(commonFlags []cli.Flag, clientConfig *types.ClientConfig)
250250

251251
appInfo := response.AppEntry
252252
if len(appInfo.Metadata.ParamValues) == 0 {
253-
fmt.Fprintf(cCtx.App.Writer, "No param values for app %s : %s\n", appInfo.AppPathDomain(), appInfo.Id)
253+
printStdout(cCtx, "No param values for app %s : %s\n", appInfo.AppPathDomain(), appInfo.Id)
254254
return nil
255255
}
256-
fmt.Fprintf(cCtx.App.Writer, "Param values for app %s : %s\n", appInfo.AppPathDomain(), appInfo.Id)
256+
printStdout(cCtx, "Param values for app %s : %s\n", appInfo.AppPathDomain(), appInfo.Id)
257257
for name, value := range appInfo.Metadata.ParamValues {
258-
fmt.Fprintf(cCtx.App.Writer, " %s: %s\n", name, value)
258+
printStdout(cCtx, " %s: %s\n", name, value)
259259
}
260260

261261
return nil

cmd/openrun/app_cmds.go

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -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

368368
func 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)

cmd/openrun/app_update_cmds.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ The second required argument is <appPathGlob>. ` + PATH_SPEC_HELP + `
7878
for _, updateResult := range updateResponse.UpdateResults {
7979
fmt.Printf("Updating %s\n", updateResult)
8080
}
81-
fmt.Fprintf(cCtx.App.Writer, "%d app(s) updated.\n", len(updateResponse.UpdateResults))
81+
printStdout(cCtx, "%d app(s) updated.\n", len(updateResponse.UpdateResults))
8282

8383
if updateResponse.DryRun {
8484
fmt.Print(DRY_RUN_MESSAGE)
@@ -140,7 +140,7 @@ The second required argument is <appPathGlob>. ` + PATH_SPEC_HELP + `
140140
for _, updateResult := range updateResponse.UpdateResults {
141141
fmt.Printf("Updating %s\n", updateResult)
142142
}
143-
fmt.Fprintf(cCtx.App.Writer, "%d app(s) updated.\n", len(updateResponse.UpdateResults))
143+
printStdout(cCtx, "%d app(s) updated.\n", len(updateResponse.UpdateResults))
144144

145145
if updateResponse.DryRun {
146146
fmt.Print(DRY_RUN_MESSAGE)
@@ -193,7 +193,7 @@ The second required argument is <appPathGlob>. ` + PATH_SPEC_HELP + `
193193
for _, updateResult := range updateResponse.UpdateResults {
194194
fmt.Printf("Updating %s\n", updateResult)
195195
}
196-
fmt.Fprintf(cCtx.App.Writer, "%d app(s) updated.\n", len(updateResponse.UpdateResults))
196+
printStdout(cCtx, "%d app(s) updated.\n", len(updateResponse.UpdateResults))
197197

198198
if updateResponse.DryRun {
199199
fmt.Print(DRY_RUN_MESSAGE)
@@ -247,7 +247,7 @@ The second required argument is <appPathGlob>. ` + PATH_SPEC_HELP + `
247247
for _, updateResult := range updateResponse.UpdateResults {
248248
fmt.Printf("Updating %s\n", updateResult)
249249
}
250-
fmt.Fprintf(cCtx.App.Writer, "%d app(s) updated.\n", len(updateResponse.UpdateResults))
250+
printStdout(cCtx, "%d app(s) updated.\n", len(updateResponse.UpdateResults))
251251

252252
if updateResponse.DryRun {
253253
fmt.Print(DRY_RUN_MESSAGE)
@@ -318,17 +318,17 @@ The last required argument is <appPathGlob>. ` + PATH_SPEC_HELP + `
318318
}
319319

320320
if len(updateResponse.PromoteResults) > 0 {
321-
fmt.Fprintf(cCtx.App.Writer, "Promoted apps: ")
321+
printStdout(cCtx, "Promoted apps: ")
322322
for i, promoteResult := range updateResponse.PromoteResults {
323323
if i > 0 {
324-
fmt.Fprintf(cCtx.App.Writer, ", ")
324+
printStdout(cCtx, ", ")
325325
}
326-
fmt.Fprintf(cCtx.App.Writer, "%s", promoteResult)
326+
printStdout(cCtx, "%s", promoteResult)
327327
}
328-
fmt.Fprintln(cCtx.App.Writer)
328+
printStdout(cCtx, "\n")
329329
}
330330

331-
fmt.Fprintf(cCtx.App.Writer, "%d app(s) updated, %d app(s) promoted.\n", len(updateResponse.StagedUpdateResults), len(updateResponse.PromoteResults))
331+
printStdout(cCtx, "%d app(s) updated, %d app(s) promoted.\n", len(updateResponse.StagedUpdateResults), len(updateResponse.PromoteResults))
332332

333333
if updateResponse.DryRun {
334334
fmt.Print(DRY_RUN_MESSAGE)
@@ -388,17 +388,17 @@ container options. The last argument is <appPathGlob>. `+PATH_SPEC_HELP+`
388388
}
389389

390390
if len(updateResponse.PromoteResults) > 0 {
391-
fmt.Fprintf(cCtx.App.Writer, "Promoted apps: ")
391+
printStdout(cCtx, "Promoted apps: ")
392392
for i, promoteResult := range updateResponse.PromoteResults {
393393
if i > 0 {
394-
fmt.Fprintf(cCtx.App.Writer, ", ")
394+
printStdout(cCtx, ", ")
395395
}
396-
fmt.Fprintf(cCtx.App.Writer, "%s", promoteResult)
396+
printStdout(cCtx, "%s", promoteResult)
397397
}
398-
fmt.Fprintln(cCtx.App.Writer)
398+
printStdout(cCtx, "\n")
399399
}
400400

401-
fmt.Fprintf(cCtx.App.Writer, "%d app(s) updated, %d app(s) promoted.\n", len(updateResponse.StagedUpdateResults), len(updateResponse.PromoteResults))
401+
printStdout(cCtx, "%d app(s) updated, %d app(s) promoted.\n", len(updateResponse.StagedUpdateResults), len(updateResponse.PromoteResults))
402402

403403
if updateResponse.DryRun {
404404
fmt.Print(DRY_RUN_MESSAGE)

0 commit comments

Comments
 (0)