@@ -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,19 @@ 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 {}
475- var cdiDeviceNames []string
476- for _ , device := range copts .devices .GetSlice () {
477- var (
478- validated string
479- deviceMapping container.DeviceMapping
480- err error
481- )
467+ devices := copts .devices .GetSlice ()
468+ deviceMappings := make ([]container.DeviceMapping , 0 , len (devices ))
469+ cdiDeviceNames := make ([]string , 0 , len (devices ))
470+ for _ , device := range devices {
482471 if cdi .IsQualifiedName (device ) {
483472 cdiDeviceNames = append (cdiDeviceNames , device )
484473 continue
485474 }
486- validated , err = validateDevice (device , serverOS )
475+ validated , err : = validateDevice (device , serverOS )
487476 if err != nil {
488477 return nil , err
489478 }
490- deviceMapping , err = parseDevice (validated , serverOS )
479+ deviceMapping , err : = parseDevice (validated , serverOS )
491480 if err != nil {
492481 return nil , err
493482 }
0 commit comments