From 82e2efbbf72a56d3c2b4520e886be1c9249ad038 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 1 Feb 2025 22:32:30 +0100 Subject: [PATCH] cli/command/context: minor cleanups - use dockerCLI with Go's standard camelCase casing. - suppress some errors to make my IDE and linters happier Signed-off-by: Sebastiaan van Stijn --- cli/command/context/create.go | 10 +++++----- cli/command/context/import.go | 4 ++-- cli/command/context/update.go | 10 +++++----- cli/command/context/use.go | 12 ++++++------ 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cli/command/context/create.go b/cli/command/context/create.go index a77151c252..a3bbeeedfc 100644 --- a/cli/command/context/create.go +++ b/cli/command/context/create.go @@ -34,11 +34,11 @@ func longCreateDescription() string { buf := bytes.NewBuffer(nil) buf.WriteString("Create a context\n\nDocker endpoint config:\n\n") tw := tabwriter.NewWriter(buf, 20, 1, 3, ' ', 0) - fmt.Fprintln(tw, "NAME\tDESCRIPTION") + _, _ = fmt.Fprintln(tw, "NAME\tDESCRIPTION") for _, d := range dockerConfigKeysDescriptions { - fmt.Fprintf(tw, "%s\t%s\n", d.name, d.description) + _, _ = fmt.Fprintf(tw, "%s\t%s\n", d.name, d.description) } - tw.Flush() + _ = tw.Flush() buf.WriteString("\nExample:\n\n$ docker context create my-context --description \"some description\" --docker \"host=tcp://myserver:2376,ca=~/ca-file,cert=~/cert-file,key=~/key-file\"\n") return buf.String() } @@ -79,8 +79,8 @@ func RunCreate(dockerCLI command.Cli, o *CreateOptions) error { err = createNewContext(s, o) } if err == nil { - fmt.Fprintln(dockerCLI.Out(), o.Name) - fmt.Fprintf(dockerCLI.Err(), "Successfully created context %q\n", o.Name) + _, _ = fmt.Fprintln(dockerCLI.Out(), o.Name) + _, _ = fmt.Fprintf(dockerCLI.Err(), "Successfully created context %q\n", o.Name) } return err } diff --git a/cli/command/context/import.go b/cli/command/context/import.go index c09f8f89f5..ff0179feb3 100644 --- a/cli/command/context/import.go +++ b/cli/command/context/import.go @@ -45,7 +45,7 @@ func RunImport(dockerCli command.Cli, name string, source string) error { return err } - fmt.Fprintln(dockerCli.Out(), name) - fmt.Fprintf(dockerCli.Err(), "Successfully imported context %q\n", name) + _, _ = fmt.Fprintln(dockerCli.Out(), name) + _, _ = fmt.Fprintf(dockerCli.Err(), "Successfully imported context %q\n", name) return nil } diff --git a/cli/command/context/update.go b/cli/command/context/update.go index 98eba7d1ec..980937e0c1 100644 --- a/cli/command/context/update.go +++ b/cli/command/context/update.go @@ -24,11 +24,11 @@ func longUpdateDescription() string { buf := bytes.NewBuffer(nil) buf.WriteString("Update a context\n\nDocker endpoint config:\n\n") tw := tabwriter.NewWriter(buf, 20, 1, 3, ' ', 0) - fmt.Fprintln(tw, "NAME\tDESCRIPTION") + _, _ = fmt.Fprintln(tw, "NAME\tDESCRIPTION") for _, d := range dockerConfigKeysDescriptions { - fmt.Fprintf(tw, "%s\t%s\n", d.name, d.description) + _, _ = fmt.Fprintf(tw, "%s\t%s\n", d.name, d.description) } - tw.Flush() + _ = tw.Flush() buf.WriteString("\nExample:\n\n$ docker context update my-context --description \"some description\" --docker \"host=tcp://myserver:2376,ca=~/ca-file,cert=~/cert-file,key=~/key-file\"\n") return buf.String() } @@ -93,8 +93,8 @@ func RunUpdate(dockerCLI command.Cli, o *UpdateOptions) error { } } - fmt.Fprintln(dockerCLI.Out(), o.Name) - fmt.Fprintf(dockerCLI.Err(), "Successfully updated context %q\n", o.Name) + _, _ = fmt.Fprintln(dockerCLI.Out(), o.Name) + _, _ = fmt.Fprintf(dockerCLI.Err(), "Successfully updated context %q\n", o.Name) return nil } diff --git a/cli/command/context/use.go b/cli/command/context/use.go index c24a0c6ecb..412df755e9 100644 --- a/cli/command/context/use.go +++ b/cli/command/context/use.go @@ -24,19 +24,19 @@ func newUseCommand(dockerCli command.Cli) *cobra.Command { } // RunUse set the current Docker context -func RunUse(dockerCli command.Cli, name string) error { +func RunUse(dockerCLI command.Cli, name string) error { // configValue uses an empty string for "default" var configValue string if name != command.DefaultContextName { if err := store.ValidateContextName(name); err != nil { return err } - if _, err := dockerCli.ContextStore().GetMetadata(name); err != nil { + if _, err := dockerCLI.ContextStore().GetMetadata(name); err != nil { return err } configValue = name } - dockerConfig := dockerCli.ConfigFile() + dockerConfig := dockerCLI.ConfigFile() // Avoid updating the config-file if nothing changed. This also prevents // creating the file and config-directory if the default is used and // no config-file existed yet. @@ -46,10 +46,10 @@ func RunUse(dockerCli command.Cli, name string) error { return err } } - fmt.Fprintln(dockerCli.Out(), name) - fmt.Fprintf(dockerCli.Err(), "Current context is now %q\n", name) + _, _ = fmt.Fprintln(dockerCLI.Out(), name) + _, _ = fmt.Fprintf(dockerCLI.Err(), "Current context is now %q\n", name) if name != command.DefaultContextName && os.Getenv(client.EnvOverrideHost) != "" { - fmt.Fprintf(dockerCli.Err(), "Warning: %[1]s environment variable overrides the active context. "+ + _, _ = fmt.Fprintf(dockerCLI.Err(), "Warning: %[1]s environment variable overrides the active context. "+ "To use %[2]q, either set the global --context flag, or unset %[1]s environment variable.\n", client.EnvOverrideHost, name) } return nil