Skip to content

Commit 46fb307

Browse files
committed
cli/command/container: inline some variables
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 74e3520 commit 46fb307

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

cli/command/container/opts.go

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -425,19 +425,12 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con
425425
entrypoint = []string{""}
426426
}
427427

428-
publishOpts := copts.publish.GetSlice()
429-
var (
430-
ports map[container.PortRangeProto]struct{}
431-
portBindings map[container.PortRangeProto][]container.PortBinding
432-
convertedOpts []string
433-
)
434-
435-
convertedOpts, err = convertToStandardNotation(publishOpts)
428+
convertedOpts, err := convertToStandardNotation(copts.publish.GetSlice())
436429
if err != nil {
437430
return nil, err
438431
}
439432

440-
ports, portBindings, err = nat.ParsePortSpecs(convertedOpts)
433+
ports, portBindings, err := nat.ParsePortSpecs(convertedOpts)
441434
if err != nil {
442435
return nil, err
443436
}
@@ -471,23 +464,18 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con
471464
// device path (as opposed to during flag parsing), as at the time we are
472465
// parsing flags, we haven't yet sent a _ping to the daemon to determine
473466
// what operating system it is.
474-
deviceMappings := []container.DeviceMapping{}
467+
var deviceMappings []container.DeviceMapping
475468
var cdiDeviceNames []string
476469
for _, device := range copts.devices.GetSlice() {
477-
var (
478-
validated string
479-
deviceMapping container.DeviceMapping
480-
err error
481-
)
482470
if cdi.IsQualifiedName(device) {
483471
cdiDeviceNames = append(cdiDeviceNames, device)
484472
continue
485473
}
486-
validated, err = validateDevice(device, serverOS)
474+
validated, err := validateDevice(device, serverOS)
487475
if err != nil {
488476
return nil, err
489477
}
490-
deviceMapping, err = parseDevice(validated, serverOS)
478+
deviceMapping, err := parseDevice(validated, serverOS)
491479
if err != nil {
492480
return nil, err
493481
}

0 commit comments

Comments
 (0)