Skip to content

Commit a27106d

Browse files
authored
chore: apply gofumpt formatting (#689)
1 parent 3432bf7 commit a27106d

14 files changed

Lines changed: 124 additions & 63 deletions

File tree

internal/client/client_test.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ func TestGetTokenWithCLIOverride(t *testing.T) {
3131
})
3232
_, err = testCert.Write([]byte("hi"))
3333
require.NoError(err)
34-
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(t,
34+
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(
35+
t,
3536
zedtesting.StringFlag{FlagName: "token", FlagValue: "t1", Changed: true},
3637
zedtesting.StringFlag{FlagName: "certificate-path", FlagValue: testCert.Name(), Changed: true},
3738
zedtesting.StringFlag{FlagName: "endpoint", FlagValue: "e1", Changed: true},
@@ -53,7 +54,8 @@ func TestGetTokenWithCLIOverride(t *testing.T) {
5354
require.Equal(&bTrue, to.NoVerifyCA)
5455

5556
// storage token takes precedence when defined
56-
cmd = zedtesting.CreateTestCobraCommandWithFlagValue(t,
57+
cmd = zedtesting.CreateTestCobraCommandWithFlagValue(
58+
t,
5759
zedtesting.StringFlag{FlagName: "token", FlagValue: "", Changed: false},
5860
zedtesting.StringFlag{FlagName: "certificate-path", FlagValue: "", Changed: false},
5961
zedtesting.StringFlag{FlagName: "endpoint", FlagValue: "", Changed: false},
@@ -80,7 +82,8 @@ func TestGetCurrentTokenWithCLIOverrideWithoutConfigFile(t *testing.T) {
8082
// When we refactored the token setting logic, we broke the workflow where zed is used without a saved
8183
// configuration. This asserts that that workflow works.
8284
require := require.New(t)
83-
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(t,
85+
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(
86+
t,
8487
zedtesting.StringFlag{FlagName: "token", FlagValue: "t1", Changed: true},
8588
zedtesting.StringFlag{FlagName: "endpoint", FlagValue: "e1", Changed: true},
8689
zedtesting.StringFlag{FlagName: "certificate-path", FlagValue: "", Changed: false},
@@ -104,7 +107,8 @@ func TestGetCurrentTokenWithCLIOverrideWithoutSecretFile(t *testing.T) {
104107
// When we refactored the token setting logic, we broke the workflow where zed is used without a saved
105108
// context. This asserts that that workflow works.
106109
require := require.New(t)
107-
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(t,
110+
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(
111+
t,
108112
zedtesting.StringFlag{FlagName: "token", FlagValue: "t1", Changed: true},
109113
zedtesting.StringFlag{FlagName: "endpoint", FlagValue: "e1", Changed: true},
110114
zedtesting.StringFlag{FlagName: "certificate-path", FlagValue: "", Changed: false},
@@ -173,7 +177,8 @@ func TestRetries(t *testing.T) {
173177

174178
secure := true
175179
retries := uint(2)
176-
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(t,
180+
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(
181+
t,
177182
zedtesting.BoolFlag{FlagName: "skip-version-check", FlagValue: true, Changed: true},
178183
zedtesting.UintFlag{FlagName: "max-retries", FlagValue: retries, Changed: true},
179184
zedtesting.StringFlag{FlagName: "proxy", FlagValue: "", Changed: true},
@@ -217,7 +222,8 @@ func TestDoesNotRetry(t *testing.T) {
217222

218223
secure := true
219224
retries := uint(2)
220-
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(t,
225+
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(
226+
t,
221227
zedtesting.BoolFlag{FlagName: "skip-version-check", FlagValue: true, Changed: true},
222228
zedtesting.UintFlag{FlagName: "max-retries", FlagValue: retries, Changed: true},
223229
zedtesting.StringFlag{FlagName: "proxy", FlagValue: "", Changed: true},

internal/cmd/backup_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ func TestBackupParseRelsCmdFunc(t *testing.T) {
176176
tt := tt
177177
t.Parallel()
178178

179-
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(t,
179+
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(
180+
t,
180181
zedtesting.StringToStringFlag{FlagName: "prefix-replacements"},
181182
zedtesting.StringFlag{FlagName: "prefix-filter", FlagValue: tt.filter},
182183
zedtesting.BoolFlag{FlagName: "rewrite-legacy"},
@@ -519,7 +520,8 @@ func validateBackupWithFunc(t testing.TB, backupFileName, schema string, token *
519520
}
520521

521522
func TestBackupRestoreCmdFunc(t *testing.T) {
522-
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(t,
523+
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(
524+
t,
523525
zedtesting.StringToStringFlag{FlagName: "prefix-replacements"},
524526
zedtesting.StringFlag{FlagName: "prefix-filter", FlagValue: "test"},
525527
zedtesting.BoolFlag{FlagName: "rewrite-legacy"},

internal/cmd/import_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ func TestImportCmd(t *testing.T) {
5353
for testName, test := range testcases {
5454
t.Run(testName, func(t *testing.T) {
5555
require := require.New(t)
56-
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(t,
56+
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(
57+
t,
5758
zedtesting.StringFlag{FlagName: "schema-definition-prefix", FlagValue: test.prefix},
5859
zedtesting.BoolFlag{FlagName: "schema", FlagValue: test.importSchema},
5960
zedtesting.BoolFlag{FlagName: "relationships", FlagValue: test.importRels},
@@ -104,7 +105,8 @@ func TestImportCmd(t *testing.T) {
104105
}
105106

106107
func TestImportCmdRelationsOnly(t *testing.T) {
107-
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(t,
108+
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(
109+
t,
108110
zedtesting.StringFlag{FlagName: "schema-definition-prefix"},
109111
zedtesting.BoolFlag{FlagName: "schema", FlagValue: false},
110112
zedtesting.BoolFlag{FlagName: "relationships", FlagValue: true},

internal/cmd/schema_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ definition resource {
170170
permission view = user
171171
}
172172
`
173-
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(t,
173+
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(
174+
t,
174175
zedtesting.StringFlag{FlagName: "out", FlagValue: tc.outFile},
175176
)
176177
usedStdout, err := schemaCompileOuter(cmd, files)
@@ -438,7 +439,8 @@ definition resource {
438439

439440
for name, tc := range testCases {
440441
t.Run(name, func(t *testing.T) {
441-
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(t,
442+
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(
443+
t,
442444
zedtesting.StringFlag{FlagName: "schema-definition-prefix", FlagValue: ""},
443445
zedtesting.BoolFlag{FlagName: "json", FlagValue: true},
444446
)

internal/cmd/validate.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,10 @@ func validateCmdFunc(cmd *cobra.Command, filenames []string) (string, bool, erro
148148
if fileType == decode.FileTypeZed {
149149
contents, readErr := os.ReadFile(filename)
150150
if readErr == nil && decode.LooksLikeYAMLValidationFile(string(contents)) {
151-
fmt.Fprintf(toPrint, "%sfile %q has a .zed extension but appears to be a YAML validation file.\n"+
152-
" Rename the file to use a .yaml extension, or use --type yaml to override:\n"+
153-
" zed validate %s --type yaml\n\n",
151+
fmt.Fprintf(
152+
toPrint, "%sfile %q has a .zed extension but appears to be a YAML validation file.\n"+
153+
" Rename the file to use a .yaml extension, or use --type yaml to override:\n"+
154+
" zed validate %s --type yaml\n\n",
154155
errorPrefix(), filename, filename,
155156
)
156157
shouldExit = true

internal/cmd/validate_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ func normalizeNewlines(s string) string {
4747
func TestValidatePreRun(t *testing.T) {
4848
t.Parallel()
4949

50-
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(t,
50+
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(
51+
t,
5152
zedtesting.BoolFlag{FlagName: "force-color", FlagValue: false},
5253
zedtesting.BoolFlag{FlagName: "fail-on-warn", FlagValue: false},
5354
zedtesting.StringFlag{FlagName: "type", FlagValue: ""},
@@ -383,7 +384,8 @@ complete - 0 relationships loaded, 0 assertions run, 0 expected relations valida
383384
t.Parallel()
384385

385386
require := require.New(t)
386-
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(t,
387+
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(
388+
t,
387389
zedtesting.IntFlag{FlagName: "batch-size", FlagValue: 100},
388390
zedtesting.IntFlag{FlagName: "workers", FlagValue: 1},
389391
zedtesting.BoolFlag{FlagName: "fail-on-warn", FlagValue: false},
@@ -409,7 +411,8 @@ func TestFailOnWarn(t *testing.T) {
409411
require := require.New(t)
410412

411413
// Run once with fail-on-warn set to false
412-
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(t,
414+
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(
415+
t,
413416
zedtesting.BoolFlag{FlagName: "force-color", FlagValue: false},
414417
zedtesting.IntFlag{FlagName: "batch-size", FlagValue: 100}, zedtesting.IntFlag{FlagName: "workers", FlagValue: 1},
415418
zedtesting.BoolFlag{FlagName: "fail-on-warn", FlagValue: false},
@@ -420,7 +423,8 @@ func TestFailOnWarn(t *testing.T) {
420423
require.False(shouldError, "validation pass should not fail without fail-on-warn")
421424

422425
// Run again with fail-on-warn set to true
423-
cmd = zedtesting.CreateTestCobraCommandWithFlagValue(t,
426+
cmd = zedtesting.CreateTestCobraCommandWithFlagValue(
427+
t,
424428
zedtesting.BoolFlag{FlagName: "force-color", FlagValue: false},
425429
zedtesting.IntFlag{FlagName: "batch-size", FlagValue: 100},
426430
zedtesting.IntFlag{FlagName: "workers", FlagValue: 1},

internal/cmd/version_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ func TestVersionCommandWithUnavailableServer(t *testing.T) {
179179
})
180180

181181
// Create command with all required flags
182-
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(t,
182+
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(
183+
t,
183184
zedtesting.BoolFlag{FlagName: "include-remote-version", FlagValue: true},
184185
zedtesting.BoolFlag{FlagName: "include-deps", FlagValue: false},
185186
zedtesting.UintFlag{FlagName: "max-retries", FlagValue: 10},

internal/commands/permission.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,8 @@ func lookupSubjectsCmdFunc(cmd *cobra.Command, args []string) error {
604604

605605
console.Println(string(prettyProto))
606606
}
607-
console.Printf("%s:%s%s\n",
607+
console.Printf(
608+
"%s:%s%s\n",
608609
subjectType,
609610
prettyLookupPermissionship(resp.Subject.SubjectObjectId, resp.Subject.Permissionship, resp.Subject.PartialCaveatInfo),
610611
excludedSubjectsString(resp.ExcludedSubjects),

internal/commands/watch.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ func processResponse(resp *v1.WatchResponse) {
164164
subjectRelation = " " + update.Relationship.Subject.OptionalRelation
165165
}
166166

167-
console.Printf("%s:%s %s %s:%s%s\n",
167+
console.Printf(
168+
"%s:%s %s %s:%s%s\n",
168169
update.Relationship.Resource.ObjectType,
169170
update.Relationship.Resource.ObjectId,
170171
update.Relationship.Relation,

internal/console/console.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ var Println = func(values ...any) {
4343

4444
// CreateProgressBar creates a new progress bar with the given description and defaults adjusted to zed's UX experience
4545
func CreateProgressBar(description string) *progressbar.ProgressBar {
46-
bar := progressbar.NewOptions(-1,
46+
bar := progressbar.NewOptions(
47+
-1,
4748
progressbar.OptionSetWidth(10),
4849
progressbar.OptionSetRenderBlankState(true),
4950
progressbar.OptionSetVisibility(false),
5051
)
5152
if isatty.IsTerminal(os.Stderr.Fd()) {
52-
bar = progressbar.NewOptions64(-1,
53+
bar = progressbar.NewOptions64(
54+
-1,
5355
progressbar.OptionSetDescription(description),
5456
progressbar.OptionSetWriter(os.Stderr),
5557
progressbar.OptionSetWidth(10),

0 commit comments

Comments
 (0)