Skip to content

Commit deaa601

Browse files
committed
cli/command/config: minor cleanups
- use apiClient instead of client for the API client to prevent shadowing imports. - use dockerCLI with Go's standard camelCase casing. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent ce30966 commit deaa601

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

cli/command/config/create.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ func newConfigCreateCommand(dockerCli command.Cli) *cobra.Command {
4848
}
4949

5050
// RunConfigCreate creates a config with the given options.
51-
func RunConfigCreate(ctx context.Context, dockerCli command.Cli, options CreateOptions) error {
52-
client := dockerCli.Client()
51+
func RunConfigCreate(ctx context.Context, dockerCLI command.Cli, options CreateOptions) error {
52+
apiClient := dockerCLI.Client()
5353

54-
var in io.Reader = dockerCli.In()
54+
var in io.Reader = dockerCLI.In()
5555
if options.File != "-" {
5656
file, err := sequential.Open(options.File)
5757
if err != nil {
@@ -78,11 +78,11 @@ func RunConfigCreate(ctx context.Context, dockerCli command.Cli, options CreateO
7878
Name: options.TemplateDriver,
7979
}
8080
}
81-
r, err := client.ConfigCreate(ctx, spec)
81+
r, err := apiClient.ConfigCreate(ctx, spec)
8282
if err != nil {
8383
return err
8484
}
8585

86-
fmt.Fprintln(dockerCli.Out(), r.ID)
86+
fmt.Fprintln(dockerCLI.Out(), r.ID)
8787
return nil
8888
}

cli/command/config/inspect.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ func newConfigInspectCommand(dockerCli command.Cli) *cobra.Command {
4343
}
4444

4545
// RunConfigInspect inspects the given Swarm config.
46-
func RunConfigInspect(ctx context.Context, dockerCli command.Cli, opts InspectOptions) error {
47-
client := dockerCli.Client()
46+
func RunConfigInspect(ctx context.Context, dockerCLI command.Cli, opts InspectOptions) error {
47+
apiClient := dockerCLI.Client()
4848

4949
if opts.Pretty {
5050
opts.Format = "pretty"
5151
}
5252

5353
getRef := func(id string) (any, []byte, error) {
54-
return client.ConfigInspectWithRaw(ctx, id)
54+
return apiClient.ConfigInspectWithRaw(ctx, id)
5555
}
5656
f := opts.Format
5757

@@ -62,7 +62,7 @@ func RunConfigInspect(ctx context.Context, dockerCli command.Cli, opts InspectOp
6262
}
6363

6464
configCtx := formatter.Context{
65-
Output: dockerCli.Out(),
65+
Output: dockerCLI.Out(),
6666
Format: NewFormat(f, false),
6767
}
6868

cli/command/config/ls.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ func newConfigListCommand(dockerCli command.Cli) *cobra.Command {
4545
}
4646

4747
// RunConfigList lists Swarm configs.
48-
func RunConfigList(ctx context.Context, dockerCli command.Cli, options ListOptions) error {
49-
client := dockerCli.Client()
48+
func RunConfigList(ctx context.Context, dockerCLI command.Cli, options ListOptions) error {
49+
apiClient := dockerCLI.Client()
5050

51-
configs, err := client.ConfigList(ctx, types.ConfigListOptions{Filters: options.Filter.Value()})
51+
configs, err := apiClient.ConfigList(ctx, types.ConfigListOptions{Filters: options.Filter.Value()})
5252
if err != nil {
5353
return err
5454
}
5555

5656
format := options.Format
5757
if len(format) == 0 {
58-
if len(dockerCli.ConfigFile().ConfigFormat) > 0 && !options.Quiet {
59-
format = dockerCli.ConfigFile().ConfigFormat
58+
if len(dockerCLI.ConfigFile().ConfigFormat) > 0 && !options.Quiet {
59+
format = dockerCLI.ConfigFile().ConfigFormat
6060
} else {
6161
format = formatter.TableFormatKey
6262
}
@@ -67,7 +67,7 @@ func RunConfigList(ctx context.Context, dockerCli command.Cli, options ListOptio
6767
})
6868

6969
configCtx := formatter.Context{
70-
Output: dockerCli.Out(),
70+
Output: dockerCLI.Out(),
7171
Format: NewFormat(format, options.Quiet),
7272
}
7373
return FormatWrite(configCtx, configs)

0 commit comments

Comments
 (0)