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>
This commit is contained in:
Sebastiaan van Stijn 2025-02-03 19:02:34 +01:00
parent ce30966636
commit deaa601189
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
3 changed files with 15 additions and 15 deletions

View File

@ -48,10 +48,10 @@ func newConfigCreateCommand(dockerCli command.Cli) *cobra.Command {
}
// RunConfigCreate creates a config with the given options.
func RunConfigCreate(ctx context.Context, dockerCli command.Cli, options CreateOptions) error {
client := dockerCli.Client()
func RunConfigCreate(ctx context.Context, dockerCLI command.Cli, options CreateOptions) error {
apiClient := dockerCLI.Client()
var in io.Reader = dockerCli.In()
var in io.Reader = dockerCLI.In()
if options.File != "-" {
file, err := sequential.Open(options.File)
if err != nil {
@ -78,11 +78,11 @@ func RunConfigCreate(ctx context.Context, dockerCli command.Cli, options CreateO
Name: options.TemplateDriver,
}
}
r, err := client.ConfigCreate(ctx, spec)
r, err := apiClient.ConfigCreate(ctx, spec)
if err != nil {
return err
}
fmt.Fprintln(dockerCli.Out(), r.ID)
fmt.Fprintln(dockerCLI.Out(), r.ID)
return nil
}

View File

@ -43,15 +43,15 @@ func newConfigInspectCommand(dockerCli command.Cli) *cobra.Command {
}
// RunConfigInspect inspects the given Swarm config.
func RunConfigInspect(ctx context.Context, dockerCli command.Cli, opts InspectOptions) error {
client := dockerCli.Client()
func RunConfigInspect(ctx context.Context, dockerCLI command.Cli, opts InspectOptions) error {
apiClient := dockerCLI.Client()
if opts.Pretty {
opts.Format = "pretty"
}
getRef := func(id string) (any, []byte, error) {
return client.ConfigInspectWithRaw(ctx, id)
return apiClient.ConfigInspectWithRaw(ctx, id)
}
f := opts.Format
@ -62,7 +62,7 @@ func RunConfigInspect(ctx context.Context, dockerCli command.Cli, opts InspectOp
}
configCtx := formatter.Context{
Output: dockerCli.Out(),
Output: dockerCLI.Out(),
Format: NewFormat(f, false),
}

View File

@ -45,18 +45,18 @@ func newConfigListCommand(dockerCli command.Cli) *cobra.Command {
}
// RunConfigList lists Swarm configs.
func RunConfigList(ctx context.Context, dockerCli command.Cli, options ListOptions) error {
client := dockerCli.Client()
func RunConfigList(ctx context.Context, dockerCLI command.Cli, options ListOptions) error {
apiClient := dockerCLI.Client()
configs, err := client.ConfigList(ctx, types.ConfigListOptions{Filters: options.Filter.Value()})
configs, err := apiClient.ConfigList(ctx, types.ConfigListOptions{Filters: options.Filter.Value()})
if err != nil {
return err
}
format := options.Format
if len(format) == 0 {
if len(dockerCli.ConfigFile().ConfigFormat) > 0 && !options.Quiet {
format = dockerCli.ConfigFile().ConfigFormat
if len(dockerCLI.ConfigFile().ConfigFormat) > 0 && !options.Quiet {
format = dockerCLI.ConfigFile().ConfigFormat
} else {
format = formatter.TableFormatKey
}
@ -67,7 +67,7 @@ func RunConfigList(ctx context.Context, dockerCli command.Cli, options ListOptio
})
configCtx := formatter.Context{
Output: dockerCli.Out(),
Output: dockerCLI.Out(),
Format: NewFormat(format, options.Quiet),
}
return FormatWrite(configCtx, configs)