Skip to content

Commit 82e2efb

Browse files
committed
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 <github@gone.nl>
1 parent c462eae commit 82e2efb

4 files changed

Lines changed: 18 additions & 18 deletions

File tree

cli/command/context/create.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ func longCreateDescription() string {
3434
buf := bytes.NewBuffer(nil)
3535
buf.WriteString("Create a context\n\nDocker endpoint config:\n\n")
3636
tw := tabwriter.NewWriter(buf, 20, 1, 3, ' ', 0)
37-
fmt.Fprintln(tw, "NAME\tDESCRIPTION")
37+
_, _ = fmt.Fprintln(tw, "NAME\tDESCRIPTION")
3838
for _, d := range dockerConfigKeysDescriptions {
39-
fmt.Fprintf(tw, "%s\t%s\n", d.name, d.description)
39+
_, _ = fmt.Fprintf(tw, "%s\t%s\n", d.name, d.description)
4040
}
41-
tw.Flush()
41+
_ = tw.Flush()
4242
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")
4343
return buf.String()
4444
}
@@ -79,8 +79,8 @@ func RunCreate(dockerCLI command.Cli, o *CreateOptions) error {
7979
err = createNewContext(s, o)
8080
}
8181
if err == nil {
82-
fmt.Fprintln(dockerCLI.Out(), o.Name)
83-
fmt.Fprintf(dockerCLI.Err(), "Successfully created context %q\n", o.Name)
82+
_, _ = fmt.Fprintln(dockerCLI.Out(), o.Name)
83+
_, _ = fmt.Fprintf(dockerCLI.Err(), "Successfully created context %q\n", o.Name)
8484
}
8585
return err
8686
}

cli/command/context/import.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func RunImport(dockerCli command.Cli, name string, source string) error {
4545
return err
4646
}
4747

48-
fmt.Fprintln(dockerCli.Out(), name)
49-
fmt.Fprintf(dockerCli.Err(), "Successfully imported context %q\n", name)
48+
_, _ = fmt.Fprintln(dockerCli.Out(), name)
49+
_, _ = fmt.Fprintf(dockerCli.Err(), "Successfully imported context %q\n", name)
5050
return nil
5151
}

cli/command/context/update.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ func longUpdateDescription() string {
2424
buf := bytes.NewBuffer(nil)
2525
buf.WriteString("Update a context\n\nDocker endpoint config:\n\n")
2626
tw := tabwriter.NewWriter(buf, 20, 1, 3, ' ', 0)
27-
fmt.Fprintln(tw, "NAME\tDESCRIPTION")
27+
_, _ = fmt.Fprintln(tw, "NAME\tDESCRIPTION")
2828
for _, d := range dockerConfigKeysDescriptions {
29-
fmt.Fprintf(tw, "%s\t%s\n", d.name, d.description)
29+
_, _ = fmt.Fprintf(tw, "%s\t%s\n", d.name, d.description)
3030
}
31-
tw.Flush()
31+
_ = tw.Flush()
3232
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")
3333
return buf.String()
3434
}
@@ -93,8 +93,8 @@ func RunUpdate(dockerCLI command.Cli, o *UpdateOptions) error {
9393
}
9494
}
9595

96-
fmt.Fprintln(dockerCLI.Out(), o.Name)
97-
fmt.Fprintf(dockerCLI.Err(), "Successfully updated context %q\n", o.Name)
96+
_, _ = fmt.Fprintln(dockerCLI.Out(), o.Name)
97+
_, _ = fmt.Fprintf(dockerCLI.Err(), "Successfully updated context %q\n", o.Name)
9898
return nil
9999
}
100100

cli/command/context/use.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ func newUseCommand(dockerCli command.Cli) *cobra.Command {
2424
}
2525

2626
// RunUse set the current Docker context
27-
func RunUse(dockerCli command.Cli, name string) error {
27+
func RunUse(dockerCLI command.Cli, name string) error {
2828
// configValue uses an empty string for "default"
2929
var configValue string
3030
if name != command.DefaultContextName {
3131
if err := store.ValidateContextName(name); err != nil {
3232
return err
3333
}
34-
if _, err := dockerCli.ContextStore().GetMetadata(name); err != nil {
34+
if _, err := dockerCLI.ContextStore().GetMetadata(name); err != nil {
3535
return err
3636
}
3737
configValue = name
3838
}
39-
dockerConfig := dockerCli.ConfigFile()
39+
dockerConfig := dockerCLI.ConfigFile()
4040
// Avoid updating the config-file if nothing changed. This also prevents
4141
// creating the file and config-directory if the default is used and
4242
// no config-file existed yet.
@@ -46,10 +46,10 @@ func RunUse(dockerCli command.Cli, name string) error {
4646
return err
4747
}
4848
}
49-
fmt.Fprintln(dockerCli.Out(), name)
50-
fmt.Fprintf(dockerCli.Err(), "Current context is now %q\n", name)
49+
_, _ = fmt.Fprintln(dockerCLI.Out(), name)
50+
_, _ = fmt.Fprintf(dockerCLI.Err(), "Current context is now %q\n", name)
5151
if name != command.DefaultContextName && os.Getenv(client.EnvOverrideHost) != "" {
52-
fmt.Fprintf(dockerCli.Err(), "Warning: %[1]s environment variable overrides the active context. "+
52+
_, _ = fmt.Fprintf(dockerCLI.Err(), "Warning: %[1]s environment variable overrides the active context. "+
5353
"To use %[2]q, either set the global --context flag, or unset %[1]s environment variable.\n", client.EnvOverrideHost, name)
5454
}
5555
return nil

0 commit comments

Comments
 (0)