Skip to content

Commit 886f229

Browse files
committed
cli/command/network: minor cleanups: use Println, rename vars
- use Println to print newline instead of custom format - use apiClient instead of client for the API client to prevent shadowing imports. - 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 5d3bdf8 commit 886f229

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

cli/command/network/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func runCreate(ctx context.Context, apiClient client.NetworkAPIClient, output io
130130
if err != nil {
131131
return err
132132
}
133-
_, _ = fmt.Fprintf(output, "%s\n", resp.ID)
133+
_, _ = fmt.Fprintln(output, resp.ID)
134134
return nil
135135
}
136136

cli/command/network/remove.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,31 @@ const ingressWarning = "WARNING! Before removing the routing-mesh network, " +
4040
"Otherwise, removal may not be effective and functionality of newly create " +
4141
"ingress networks will be impaired.\nAre you sure you want to continue?"
4242

43-
func runRemove(ctx context.Context, dockerCli command.Cli, networks []string, opts *removeOptions) error {
44-
client := dockerCli.Client()
43+
func runRemove(ctx context.Context, dockerCLI command.Cli, networks []string, opts *removeOptions) error {
44+
apiClient := dockerCLI.Client()
4545

4646
status := 0
4747

4848
for _, name := range networks {
49-
nw, _, err := client.NetworkInspectWithRaw(ctx, name, network.InspectOptions{})
49+
nw, _, err := apiClient.NetworkInspectWithRaw(ctx, name, network.InspectOptions{})
5050
if err == nil && nw.Ingress {
51-
r, err := command.PromptForConfirmation(ctx, dockerCli.In(), dockerCli.Out(), ingressWarning)
51+
r, err := command.PromptForConfirmation(ctx, dockerCLI.In(), dockerCLI.Out(), ingressWarning)
5252
if err != nil {
5353
return err
5454
}
5555
if !r {
5656
continue
5757
}
5858
}
59-
if err := client.NetworkRemove(ctx, name); err != nil {
59+
if err := apiClient.NetworkRemove(ctx, name); err != nil {
6060
if opts.force && errdefs.IsNotFound(err) {
6161
continue
6262
}
63-
_, _ = fmt.Fprintf(dockerCli.Err(), "%s\n", err)
63+
_, _ = fmt.Fprintln(dockerCLI.Err(), err)
6464
status = 1
6565
continue
6666
}
67-
_, _ = fmt.Fprintf(dockerCli.Out(), "%s\n", name)
67+
_, _ = fmt.Fprintln(dockerCLI.Out(), name)
6868
}
6969

7070
if status != 0 {

0 commit comments

Comments
 (0)