Skip to content

Commit 5cfc89c

Browse files
committed
cli/command/system: minor cleanups: use Println, rename vars
- use Println to print newline instead of custom format - 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 8c5e85d commit 5cfc89c

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

cli/command/system/events.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ const rfc3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"
121121
// Actor attributes are printed at the end if the actor has any.
122122
func prettyPrintEvent(out io.Writer, event events.Message) error {
123123
if event.TimeNano != 0 {
124-
fmt.Fprintf(out, "%s ", time.Unix(0, event.TimeNano).Format(rfc3339NanoFixed))
124+
_, _ = fmt.Fprintf(out, "%s ", time.Unix(0, event.TimeNano).Format(rfc3339NanoFixed))
125125
} else if event.Time != 0 {
126-
fmt.Fprintf(out, "%s ", time.Unix(event.Time, 0).Format(rfc3339NanoFixed))
126+
_, _ = fmt.Fprintf(out, "%s ", time.Unix(event.Time, 0).Format(rfc3339NanoFixed))
127127
}
128128

129-
fmt.Fprintf(out, "%s %s %s", event.Type, event.Action, event.Actor.ID)
129+
_, _ = fmt.Fprintf(out, "%s %s %s", event.Type, event.Action, event.Actor.ID)
130130

131131
if len(event.Actor.Attributes) > 0 {
132132
var attrs []string
@@ -139,9 +139,9 @@ func prettyPrintEvent(out io.Writer, event events.Message) error {
139139
v := event.Actor.Attributes[k]
140140
attrs = append(attrs, k+"="+v)
141141
}
142-
fmt.Fprintf(out, " (%s)", strings.Join(attrs, ", "))
142+
_, _ = fmt.Fprintf(out, " (%s)", strings.Join(attrs, ", "))
143143
}
144-
fmt.Fprint(out, "\n")
144+
_, _ = fmt.Fprint(out, "\n")
145145
return nil
146146
}
147147

cli/command/system/inspect.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func inspectConfig(ctx context.Context, dockerCLI command.Cli) inspect.GetRefFun
120120
}
121121
}
122122

123-
func inspectAll(ctx context.Context, dockerCli command.Cli, getSize bool, typeConstraint string) inspect.GetRefFunc {
123+
func inspectAll(ctx context.Context, dockerCLI command.Cli, getSize bool, typeConstraint string) inspect.GetRefFunc {
124124
inspectAutodetect := []struct {
125125
objectType string
126126
isSizeSupported bool
@@ -130,57 +130,57 @@ func inspectAll(ctx context.Context, dockerCli command.Cli, getSize bool, typeCo
130130
{
131131
objectType: "container",
132132
isSizeSupported: true,
133-
objectInspector: inspectContainers(ctx, dockerCli, getSize),
133+
objectInspector: inspectContainers(ctx, dockerCLI, getSize),
134134
},
135135
{
136136
objectType: "image",
137-
objectInspector: inspectImages(ctx, dockerCli),
137+
objectInspector: inspectImages(ctx, dockerCLI),
138138
},
139139
{
140140
objectType: "network",
141-
objectInspector: inspectNetwork(ctx, dockerCli),
141+
objectInspector: inspectNetwork(ctx, dockerCLI),
142142
},
143143
{
144144
objectType: "volume",
145-
objectInspector: inspectVolume(ctx, dockerCli),
145+
objectInspector: inspectVolume(ctx, dockerCLI),
146146
},
147147
{
148148
objectType: "service",
149149
isSwarmObject: true,
150-
objectInspector: inspectService(ctx, dockerCli),
150+
objectInspector: inspectService(ctx, dockerCLI),
151151
},
152152
{
153153
objectType: "task",
154154
isSwarmObject: true,
155-
objectInspector: inspectTasks(ctx, dockerCli),
155+
objectInspector: inspectTasks(ctx, dockerCLI),
156156
},
157157
{
158158
objectType: "node",
159159
isSwarmObject: true,
160-
objectInspector: inspectNode(ctx, dockerCli),
160+
objectInspector: inspectNode(ctx, dockerCLI),
161161
},
162162
{
163163
objectType: "plugin",
164-
objectInspector: inspectPlugin(ctx, dockerCli),
164+
objectInspector: inspectPlugin(ctx, dockerCLI),
165165
},
166166
{
167167
objectType: "secret",
168168
isSwarmObject: true,
169-
objectInspector: inspectSecret(ctx, dockerCli),
169+
objectInspector: inspectSecret(ctx, dockerCLI),
170170
},
171171
{
172172
objectType: "config",
173173
isSwarmObject: true,
174-
objectInspector: inspectConfig(ctx, dockerCli),
174+
objectInspector: inspectConfig(ctx, dockerCLI),
175175
},
176176
}
177177

178178
// isSwarmManager does an Info API call to verify that the daemon is
179179
// a swarm manager.
180180
isSwarmManager := func() bool {
181-
info, err := dockerCli.Client().Info(ctx)
181+
info, err := dockerCLI.Client().Info(ctx)
182182
if err != nil {
183-
fmt.Fprintln(dockerCli.Err(), err)
183+
_, _ = fmt.Fprintln(dockerCLI.Err(), err)
184184
return false
185185
}
186186
return info.Swarm.ControlAvailable
@@ -219,7 +219,7 @@ func inspectAll(ctx context.Context, dockerCli command.Cli, getSize bool, typeCo
219219
return v, raw, err
220220
}
221221
if getSize && !inspectData.isSizeSupported {
222-
fmt.Fprintf(dockerCli.Err(), "WARNING: --size ignored for %s\n", inspectData.objectType)
222+
_, _ = fmt.Fprintln(dockerCLI.Err(), "WARNING: --size ignored for", inspectData.objectType)
223223
}
224224
return v, raw, err
225225
}

0 commit comments

Comments
 (0)