From 22a573649d46f1f5ffe000b0d3f174b00f49a0b6 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 23 Apr 2025 12:26:24 +0200 Subject: [PATCH] cli/command: change uses of ListOpts.GetAll for GetSlice The `GetSlice()` function is part of cobra's [cobra.SliceValue] interface, and duplicates the older `GetAll()` method. This patch changes our use of the `GetAll()` method with the intent to deprecated it in future. [cobra.SliceValue]: https://pkg.go.dev/github.com/spf13/cobra@v1.9.1#SliceValue Signed-off-by: Sebastiaan van Stijn --- cli/command/config/create.go | 2 +- cli/command/container/commit.go | 2 +- cli/command/container/create.go | 2 +- cli/command/container/exec.go | 2 +- cli/command/container/opts.go | 38 ++++++++++++++--------------- cli/command/container/run.go | 2 +- cli/command/image/build.go | 8 +++---- cli/command/image/import.go | 2 +- cli/command/network/connect.go | 2 +- cli/command/network/create.go | 2 +- cli/command/node/update.go | 4 ++-- cli/command/secret/create.go | 2 +- cli/command/service/opts.go | 24 +++++++++---------- cli/command/service/update.go | 42 ++++++++++++++++----------------- cli/command/trust/signer_add.go | 2 +- cli/command/volume/create.go | 6 ++--- 16 files changed, 71 insertions(+), 71 deletions(-) diff --git a/cli/command/config/create.go b/cli/command/config/create.go index 5c27b270d1..8fefd19d59 100644 --- a/cli/command/config/create.go +++ b/cli/command/config/create.go @@ -59,7 +59,7 @@ func RunConfigCreate(ctx context.Context, dockerCLI command.Cli, options CreateO spec := swarm.ConfigSpec{ Annotations: swarm.Annotations{ Name: options.Name, - Labels: opts.ConvertKVStringsToMap(options.Labels.GetAll()), + Labels: opts.ConvertKVStringsToMap(options.Labels.GetSlice()), }, Data: configData, } diff --git a/cli/command/container/commit.go b/cli/command/container/commit.go index 076c38b692..8c8c798f68 100644 --- a/cli/command/container/commit.go +++ b/cli/command/container/commit.go @@ -61,7 +61,7 @@ func runCommit(ctx context.Context, dockerCli command.Cli, options *commitOption Reference: options.reference, Comment: options.comment, Author: options.author, - Changes: options.changes.GetAll(), + Changes: options.changes.GetSlice(), Pause: options.pause, }) if err != nil { diff --git a/cli/command/container/create.go b/cli/command/container/create.go index 8d29cbf2a5..825b7110d3 100644 --- a/cli/command/container/create.go +++ b/cli/command/container/create.go @@ -109,7 +109,7 @@ func runCreate(ctx context.Context, dockerCli command.Cli, flags *pflag.FlagSet, StatusCode: 125, } } - proxyConfig := dockerCli.ConfigFile().ParseProxyConfig(dockerCli.Client().DaemonHost(), opts.ConvertKVStringsToMapWithNil(copts.env.GetAll())) + proxyConfig := dockerCli.ConfigFile().ParseProxyConfig(dockerCli.Client().DaemonHost(), opts.ConvertKVStringsToMapWithNil(copts.env.GetSlice())) newEnv := []string{} for k, v := range proxyConfig { if v == nil { diff --git a/cli/command/container/exec.go b/cli/command/container/exec.go index 2d5eca230d..00f58ede18 100644 --- a/cli/command/container/exec.go +++ b/cli/command/container/exec.go @@ -229,7 +229,7 @@ func parseExec(execOpts ExecOptions, configFile *configfile.ConfigFile) (*contai // collect all the environment variables for the container var err error - if execOptions.Env, err = opts.ReadKVEnvStrings(execOpts.EnvFile.GetAll(), execOpts.Env.GetAll()); err != nil { + if execOptions.Env, err = opts.ReadKVEnvStrings(execOpts.EnvFile.GetSlice(), execOpts.Env.GetSlice()); err != nil { return nil, err } diff --git a/cli/command/container/opts.go b/cli/command/container/opts.go index 017503a7f3..8883271f67 100644 --- a/cli/command/container/opts.go +++ b/cli/command/container/opts.go @@ -396,7 +396,7 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con // Can't evaluate options passed into --tmpfs until we actually mount tmpfs := make(map[string]string) - for _, t := range copts.tmpfs.GetAll() { + for _, t := range copts.tmpfs.GetSlice() { k, v, _ := strings.Cut(t, ":") tmpfs[k] = v } @@ -417,7 +417,7 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con entrypoint = []string{""} } - publishOpts := copts.publish.GetAll() + publishOpts := copts.publish.GetSlice() var ( ports map[nat.Port]struct{} portBindings map[nat.Port][]nat.PortBinding @@ -435,7 +435,7 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con } // Merge in exposed ports to the map of published ports - for _, e := range copts.expose.GetAll() { + for _, e := range copts.expose.GetSlice() { if strings.Contains(e, ":") { return nil, errors.Errorf("invalid port format for --expose: %s", e) } @@ -465,7 +465,7 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con // what operating system it is. deviceMappings := []container.DeviceMapping{} var cdiDeviceNames []string - for _, device := range copts.devices.GetAll() { + for _, device := range copts.devices.GetSlice() { var ( validated string deviceMapping container.DeviceMapping @@ -487,13 +487,13 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con } // collect all the environment variables for the container - envVariables, err := opts.ReadKVEnvStrings(copts.envFile.GetAll(), copts.env.GetAll()) + envVariables, err := opts.ReadKVEnvStrings(copts.envFile.GetSlice(), copts.env.GetSlice()) if err != nil { return nil, err } // collect all the labels for the container - labels, err := opts.ReadKVStrings(copts.labelsFile.GetAll(), copts.labels.GetAll()) + labels, err := opts.ReadKVStrings(copts.labelsFile.GetSlice(), copts.labels.GetSlice()) if err != nil { return nil, err } @@ -523,19 +523,19 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con return nil, err } - loggingOpts, err := parseLoggingOpts(copts.loggingDriver, copts.loggingOpts.GetAll()) + loggingOpts, err := parseLoggingOpts(copts.loggingDriver, copts.loggingOpts.GetSlice()) if err != nil { return nil, err } - securityOpts, err := parseSecurityOpts(copts.securityOpt.GetAll()) + securityOpts, err := parseSecurityOpts(copts.securityOpt.GetSlice()) if err != nil { return nil, err } securityOpts, maskedPaths, readonlyPaths := parseSystemPaths(securityOpts) - storageOpts, err := parseStorageOpts(copts.storageOpt.GetAll()) + storageOpts, err := parseStorageOpts(copts.storageOpt.GetSlice()) if err != nil { return nil, err } @@ -621,7 +621,7 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con IOMaximumIOps: copts.ioMaxIOps, IOMaximumBandwidth: uint64(copts.ioMaxBandwidth), Ulimits: copts.ulimits.GetList(), - DeviceCgroupRules: copts.deviceCgroupRules.GetAll(), + DeviceCgroupRules: copts.deviceCgroupRules.GetSlice(), Devices: deviceMappings, DeviceRequests: deviceRequests, } @@ -658,7 +658,7 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con AutoRemove: copts.autoRemove, Privileged: copts.privileged, PortBindings: portBindings, - Links: copts.links.GetAll(), + Links: copts.links.GetSlice(), PublishAllPorts: copts.publishAll, // Make sure the dns fields are never nil. // New containers don't ever have those fields nil, @@ -668,17 +668,17 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con DNS: copts.dns.GetAllOrEmpty(), DNSSearch: copts.dnsSearch.GetAllOrEmpty(), DNSOptions: copts.dnsOptions.GetAllOrEmpty(), - ExtraHosts: copts.extraHosts.GetAll(), - VolumesFrom: copts.volumesFrom.GetAll(), + ExtraHosts: copts.extraHosts.GetSlice(), + VolumesFrom: copts.volumesFrom.GetSlice(), IpcMode: container.IpcMode(copts.ipcMode), NetworkMode: container.NetworkMode(copts.netMode.NetworkMode()), PidMode: pidMode, UTSMode: utsMode, UsernsMode: usernsMode, CgroupnsMode: cgroupnsMode, - CapAdd: strslice.StrSlice(copts.capAdd.GetAll()), - CapDrop: strslice.StrSlice(copts.capDrop.GetAll()), - GroupAdd: copts.groupAdd.GetAll(), + CapAdd: strslice.StrSlice(copts.capAdd.GetSlice()), + CapDrop: strslice.StrSlice(copts.capDrop.GetSlice()), + GroupAdd: copts.groupAdd.GetSlice(), RestartPolicy: restartPolicy, SecurityOpt: securityOpts, StorageOpt: storageOpts, @@ -822,13 +822,13 @@ func applyContainerOptions(n *opts.NetworkAttachmentOpts, copts *containerOption } if copts.aliases.Len() > 0 { n.Aliases = make([]string, copts.aliases.Len()) - copy(n.Aliases, copts.aliases.GetAll()) + copy(n.Aliases, copts.aliases.GetSlice()) } // For a user-defined network, "--link" is an endpoint option, it creates an alias. But, // for the default bridge it defines a legacy-link. if container.NetworkMode(n.Target).IsUserDefined() && copts.links.Len() > 0 { n.Links = make([]string, copts.links.Len()) - copy(n.Links, copts.links.GetAll()) + copy(n.Links, copts.links.GetSlice()) } if copts.ipv4Address != "" { n.IPv4Address = copts.ipv4Address @@ -841,7 +841,7 @@ func applyContainerOptions(n *opts.NetworkAttachmentOpts, copts *containerOption } if copts.linkLocalIPs.Len() > 0 { n.LinkLocalIPs = make([]string, copts.linkLocalIPs.Len()) - copy(n.LinkLocalIPs, copts.linkLocalIPs.GetAll()) + copy(n.LinkLocalIPs, copts.linkLocalIPs.GetSlice()) } return nil } diff --git a/cli/command/container/run.go b/cli/command/container/run.go index efbc457b23..b86ad9d5b2 100644 --- a/cli/command/container/run.go +++ b/cli/command/container/run.go @@ -90,7 +90,7 @@ func runRun(ctx context.Context, dockerCli command.Cli, flags *pflag.FlagSet, ro StatusCode: 125, } } - proxyConfig := dockerCli.ConfigFile().ParseProxyConfig(dockerCli.Client().DaemonHost(), opts.ConvertKVStringsToMapWithNil(copts.env.GetAll())) + proxyConfig := dockerCli.ConfigFile().ParseProxyConfig(dockerCli.Client().DaemonHost(), opts.ConvertKVStringsToMapWithNil(copts.env.GetSlice())) newEnv := []string{} for k, v := range proxyConfig { if v == nil { diff --git a/cli/command/image/build.go b/cli/command/image/build.go index 3fa145ac30..10f4f83dfe 100644 --- a/cli/command/image/build.go +++ b/cli/command/image/build.go @@ -545,7 +545,7 @@ func imageBuildOptions(dockerCli command.Cli, options buildOptions) types.ImageB return types.ImageBuildOptions{ Memory: options.memory.Value(), MemorySwap: options.memorySwap.Value(), - Tags: options.tags.GetAll(), + Tags: options.tags.GetSlice(), SuppressOutput: options.quiet, NoCache: options.noCache, Remove: options.rm, @@ -560,13 +560,13 @@ func imageBuildOptions(dockerCli command.Cli, options buildOptions) types.ImageB CgroupParent: options.cgroupParent, ShmSize: options.shmSize.Value(), Ulimits: options.ulimits.GetList(), - BuildArgs: configFile.ParseProxyConfig(dockerCli.Client().DaemonHost(), opts.ConvertKVStringsToMapWithNil(options.buildArgs.GetAll())), - Labels: opts.ConvertKVStringsToMap(options.labels.GetAll()), + BuildArgs: configFile.ParseProxyConfig(dockerCli.Client().DaemonHost(), opts.ConvertKVStringsToMapWithNil(options.buildArgs.GetSlice())), + Labels: opts.ConvertKVStringsToMap(options.labels.GetSlice()), CacheFrom: options.cacheFrom, SecurityOpt: options.securityOpt, NetworkMode: options.networkMode, Squash: options.squash, - ExtraHosts: options.extraHosts.GetAll(), + ExtraHosts: options.extraHosts.GetSlice(), Target: options.target, Platform: options.platform, } diff --git a/cli/command/image/import.go b/cli/command/image/import.go index eb05d9f609..50206a3ec5 100644 --- a/cli/command/image/import.go +++ b/cli/command/image/import.go @@ -82,7 +82,7 @@ func runImport(ctx context.Context, dockerCli command.Cli, options importOptions responseBody, err := dockerCli.Client().ImageImport(ctx, source, options.reference, image.ImportOptions{ Message: options.message, - Changes: options.changes.GetAll(), + Changes: options.changes.GetSlice(), Platform: options.platform, }) if err != nil { diff --git a/cli/command/network/connect.go b/cli/command/network/connect.go index 9ffd25c85e..e24976ec7e 100644 --- a/cli/command/network/connect.go +++ b/cli/command/network/connect.go @@ -72,7 +72,7 @@ func runConnect(ctx context.Context, apiClient client.NetworkAPIClient, options IPv6Address: options.ipv6address, LinkLocalIPs: options.linklocalips, }, - Links: options.links.GetAll(), + Links: options.links.GetSlice(), Aliases: options.aliases, DriverOpts: driverOpts, GwPriority: options.gwPriority, diff --git a/cli/command/network/create.go b/cli/command/network/create.go index 9331a6d7f1..7bb8b2a157 100644 --- a/cli/command/network/create.go +++ b/cli/command/network/create.go @@ -125,7 +125,7 @@ func runCreate(ctx context.Context, apiClient client.NetworkAPIClient, output io Scope: options.scope, ConfigOnly: options.configOnly, ConfigFrom: configFrom, - Labels: opts.ConvertKVStringsToMap(options.labels.GetAll()), + Labels: opts.ConvertKVStringsToMap(options.labels.GetSlice()), }) if err != nil { return err diff --git a/cli/command/node/update.go b/cli/command/node/update.go index a225dbb1b0..0c0d3bdc28 100644 --- a/cli/command/node/update.go +++ b/cli/command/node/update.go @@ -101,13 +101,13 @@ func mergeNodeUpdate(flags *pflag.FlagSet) func(*swarm.Node) error { spec.Annotations.Labels = make(map[string]string) } if flags.Changed(flagLabelAdd) { - labels := flags.Lookup(flagLabelAdd).Value.(*opts.ListOpts).GetAll() + labels := flags.Lookup(flagLabelAdd).Value.(*opts.ListOpts).GetSlice() for k, v := range opts.ConvertKVStringsToMap(labels) { spec.Annotations.Labels[k] = v } } if flags.Changed(flagLabelRemove) { - keys := flags.Lookup(flagLabelRemove).Value.(*opts.ListOpts).GetAll() + keys := flags.Lookup(flagLabelRemove).Value.(*opts.ListOpts).GetSlice() for _, k := range keys { // if a key doesn't exist, fail the command explicitly if _, exists := spec.Annotations.Labels[k]; !exists { diff --git a/cli/command/secret/create.go b/cli/command/secret/create.go index dd8a834135..0797524701 100644 --- a/cli/command/secret/create.go +++ b/cli/command/secret/create.go @@ -68,7 +68,7 @@ func runSecretCreate(ctx context.Context, dockerCli command.Cli, options createO spec := swarm.SecretSpec{ Annotations: swarm.Annotations{ Name: options.name, - Labels: opts.ConvertKVStringsToMap(options.labels.GetAll()), + Labels: opts.ConvertKVStringsToMap(options.labels.GetSlice()), }, Data: secretData, } diff --git a/cli/command/service/opts.go b/cli/command/service/opts.go index b2211bb155..b4346cf080 100644 --- a/cli/command/service/opts.go +++ b/cli/command/service/opts.go @@ -422,7 +422,7 @@ func (ldo *logDriverOptions) toLogDriver() *swarm.Driver { // set the log driver only if specified. return &swarm.Driver{ Name: ldo.name, - Options: opts.ConvertKVStringsToMap(ldo.opts.GetAll()), + Options: opts.ConvertKVStringsToMap(ldo.opts.GetSlice()), } } @@ -639,7 +639,7 @@ func (options *serviceOptions) ToStopGracePeriod(flags *pflag.FlagSet) *time.Dur // makeEnv gets the environment variables from the command line options and // returns a slice of strings to use in the service spec when doing ToService func (options *serviceOptions) makeEnv() ([]string, error) { - envVariables, err := opts.ReadKVEnvStrings(options.envFile.GetAll(), options.env.GetAll()) + envVariables, err := opts.ReadKVEnvStrings(options.envFile.GetSlice(), options.env.GetSlice()) if err != nil { return nil, err } @@ -712,12 +712,12 @@ func (options *serviceOptions) ToService(ctx context.Context, apiClient client.N return service, err } - capAdd, capDrop := opts.EffectiveCapAddCapDrop(options.capAdd.GetAll(), options.capDrop.GetAll()) + capAdd, capDrop := opts.EffectiveCapAddCapDrop(options.capAdd.GetSlice(), options.capDrop.GetSlice()) service = swarm.ServiceSpec{ Annotations: swarm.Annotations{ Name: options.name, - Labels: opts.ConvertKVStringsToMap(options.labels.GetAll()), + Labels: opts.ConvertKVStringsToMap(options.labels.GetSlice()), }, TaskTemplate: swarm.TaskSpec{ ContainerSpec: &swarm.ContainerSpec{ @@ -726,25 +726,25 @@ func (options *serviceOptions) ToService(ctx context.Context, apiClient client.N Command: options.entrypoint.Value(), Env: currentEnv, Hostname: options.hostname, - Labels: opts.ConvertKVStringsToMap(options.containerLabels.GetAll()), + Labels: opts.ConvertKVStringsToMap(options.containerLabels.GetSlice()), Dir: options.workdir, User: options.user, - Groups: options.groups.GetAll(), + Groups: options.groups.GetSlice(), StopSignal: options.stopSignal, TTY: options.tty, ReadOnly: options.readOnly, Mounts: options.mounts.Value(), Init: &options.init, DNSConfig: &swarm.DNSConfig{ - Nameservers: options.dns.GetAll(), - Search: options.dnsSearch.GetAll(), - Options: options.dnsOption.GetAll(), + Nameservers: options.dns.GetSlice(), + Search: options.dnsSearch.GetSlice(), + Options: options.dnsOption.GetSlice(), }, - Hosts: convertExtraHostsToSwarmHosts(options.hosts.GetAll()), + Hosts: convertExtraHostsToSwarmHosts(options.hosts.GetSlice()), StopGracePeriod: options.ToStopGracePeriod(flags), Healthcheck: healthConfig, Isolation: container.Isolation(options.isolation), - Sysctls: opts.ConvertKVStringsToMap(options.sysctls.GetAll()), + Sysctls: opts.ConvertKVStringsToMap(options.sysctls.GetSlice()), CapabilityAdd: capAdd, CapabilityDrop: capDrop, Ulimits: options.ulimits.GetList(), @@ -754,7 +754,7 @@ func (options *serviceOptions) ToService(ctx context.Context, apiClient client.N Resources: resources, RestartPolicy: options.restartPolicy.ToRestartPolicy(flags), Placement: &swarm.Placement{ - Constraints: options.constraints.GetAll(), + Constraints: options.constraints.GetSlice(), Preferences: options.placementPrefs.prefs, MaxReplicas: options.maxReplicas, }, diff --git a/cli/command/service/update.go b/cli/command/service/update.go index 3041f2063a..ec70d3d988 100644 --- a/cli/command/service/update.go +++ b/cli/command/service/update.go @@ -582,7 +582,7 @@ func addGenericResources(flags *pflag.FlagSet, spec *swarm.TaskSpec) error { spec.Resources.Reservations = &swarm.Resources{} } - values := flags.Lookup(flagGenericResourcesAdd).Value.(*opts.ListOpts).GetAll() + values := flags.Lookup(flagGenericResourcesAdd).Value.(*opts.ListOpts).GetSlice() generic, err := ParseGenericResources(values) if err != nil { return err @@ -616,7 +616,7 @@ func removeGenericResources(flags *pflag.FlagSet, spec *swarm.TaskSpec) error { spec.Resources.Reservations = &swarm.Resources{} } - values := flags.Lookup(flagGenericResourcesRemove).Value.(*opts.ListOpts).GetAll() + values := flags.Lookup(flagGenericResourcesRemove).Value.(*opts.ListOpts).GetSlice() m, err := buildGenericResourceMap(spec.Resources.Reservations.GenericResources) if err != nil { @@ -637,7 +637,7 @@ func removeGenericResources(flags *pflag.FlagSet, spec *swarm.TaskSpec) error { func updatePlacementConstraints(flags *pflag.FlagSet, placement *swarm.Placement) { if flags.Changed(flagConstraintAdd) { - values := flags.Lookup(flagConstraintAdd).Value.(*opts.ListOpts).GetAll() + values := flags.Lookup(flagConstraintAdd).Value.(*opts.ListOpts).GetSlice() placement.Constraints = append(placement.Constraints, values...) } toRemove := buildToRemoveSet(flags, flagConstraintRemove) @@ -684,7 +684,7 @@ func updatePlacementPreferences(flags *pflag.FlagSet, placement *swarm.Placement func updateContainerLabels(flags *pflag.FlagSet, field *map[string]string) { if *field != nil && flags.Changed(flagContainerLabelRemove) { - toRemove := flags.Lookup(flagContainerLabelRemove).Value.(*opts.ListOpts).GetAll() + toRemove := flags.Lookup(flagContainerLabelRemove).Value.(*opts.ListOpts).GetSlice() for _, label := range toRemove { delete(*field, label) } @@ -694,7 +694,7 @@ func updateContainerLabels(flags *pflag.FlagSet, field *map[string]string) { *field = map[string]string{} } - values := flags.Lookup(flagContainerLabelAdd).Value.(*opts.ListOpts).GetAll() + values := flags.Lookup(flagContainerLabelAdd).Value.(*opts.ListOpts).GetSlice() for key, value := range opts.ConvertKVStringsToMap(values) { (*field)[key] = value } @@ -703,7 +703,7 @@ func updateContainerLabels(flags *pflag.FlagSet, field *map[string]string) { func updateLabels(flags *pflag.FlagSet, field *map[string]string) { if *field != nil && flags.Changed(flagLabelRemove) { - toRemove := flags.Lookup(flagLabelRemove).Value.(*opts.ListOpts).GetAll() + toRemove := flags.Lookup(flagLabelRemove).Value.(*opts.ListOpts).GetSlice() for _, label := range toRemove { delete(*field, label) } @@ -713,7 +713,7 @@ func updateLabels(flags *pflag.FlagSet, field *map[string]string) { *field = map[string]string{} } - values := flags.Lookup(flagLabelAdd).Value.(*opts.ListOpts).GetAll() + values := flags.Lookup(flagLabelAdd).Value.(*opts.ListOpts).GetSlice() for key, value := range opts.ConvertKVStringsToMap(values) { (*field)[key] = value } @@ -722,7 +722,7 @@ func updateLabels(flags *pflag.FlagSet, field *map[string]string) { func updateSysCtls(flags *pflag.FlagSet, field *map[string]string) { if *field != nil && flags.Changed(flagSysCtlRemove) { - values := flags.Lookup(flagSysCtlRemove).Value.(*opts.ListOpts).GetAll() + values := flags.Lookup(flagSysCtlRemove).Value.(*opts.ListOpts).GetSlice() for key := range opts.ConvertKVStringsToMap(values) { delete(*field, key) } @@ -732,7 +732,7 @@ func updateSysCtls(flags *pflag.FlagSet, field *map[string]string) { *field = map[string]string{} } - values := flags.Lookup(flagSysCtlAdd).Value.(*opts.ListOpts).GetAll() + values := flags.Lookup(flagSysCtlAdd).Value.(*opts.ListOpts).GetSlice() for key, value := range opts.ConvertKVStringsToMap(values) { (*field)[key] = value } @@ -746,7 +746,7 @@ func updateUlimits(flags *pflag.FlagSet, ulimits []*container.Ulimit) []*contain newUlimits[ulimit.Name] = ulimit } if flags.Changed(flagUlimitRemove) { - values := flags.Lookup(flagUlimitRemove).Value.(*opts.ListOpts).GetAll() + values := flags.Lookup(flagUlimitRemove).Value.(*opts.ListOpts).GetSlice() for key := range opts.ConvertKVStringsToMap(values) { delete(newUlimits, key) } @@ -781,7 +781,7 @@ func updateEnvironment(flags *pflag.FlagSet, field *[]string) { } value := flags.Lookup(flagEnvAdd).Value.(*opts.ListOpts) - for _, v := range value.GetAll() { + for _, v := range value.GetSlice() { envSet[envKey(v)] = v } @@ -923,7 +923,7 @@ func buildToRemoveSet(flags *pflag.FlagSet, flag string) map[string]struct{} { return toRemove } - toRemoveSlice := flags.Lookup(flag).Value.(*opts.ListOpts).GetAll() + toRemoveSlice := flags.Lookup(flag).Value.(*opts.ListOpts).GetSlice() for _, key := range toRemoveSlice { toRemove[key] = empty } @@ -988,7 +988,7 @@ func updateMounts(flags *pflag.FlagSet, mounts *[]mounttypes.Mount) error { func updateGroups(flags *pflag.FlagSet, groups *[]string) error { if flags.Changed(flagGroupAdd) { - values := flags.Lookup(flagGroupAdd).Value.(*opts.ListOpts).GetAll() + values := flags.Lookup(flagGroupAdd).Value.(*opts.ListOpts).GetSlice() *groups = append(*groups, values...) } toRemove := buildToRemoveSet(flags, flagGroupRemove) @@ -1023,7 +1023,7 @@ func updateDNSConfig(flags *pflag.FlagSet, config **swarm.DNSConfig) error { nameservers := (*config).Nameservers if flags.Changed(flagDNSAdd) { - values := flags.Lookup(flagDNSAdd).Value.(*opts.ListOpts).GetAll() + values := flags.Lookup(flagDNSAdd).Value.(*opts.ListOpts).GetSlice() nameservers = append(nameservers, values...) } nameservers = removeDuplicates(nameservers) @@ -1038,7 +1038,7 @@ func updateDNSConfig(flags *pflag.FlagSet, config **swarm.DNSConfig) error { search := (*config).Search if flags.Changed(flagDNSSearchAdd) { - values := flags.Lookup(flagDNSSearchAdd).Value.(*opts.ListOpts).GetAll() + values := flags.Lookup(flagDNSSearchAdd).Value.(*opts.ListOpts).GetSlice() search = append(search, values...) } search = removeDuplicates(search) @@ -1053,7 +1053,7 @@ func updateDNSConfig(flags *pflag.FlagSet, config **swarm.DNSConfig) error { options := (*config).Options if flags.Changed(flagDNSOptionAdd) { - values := flags.Lookup(flagDNSOptionAdd).Value.(*opts.ListOpts).GetAll() + values := flags.Lookup(flagDNSOptionAdd).Value.(*opts.ListOpts).GetSlice() options = append(options, values...) } options = removeDuplicates(options) @@ -1202,7 +1202,7 @@ type hostMapping struct { func updateHosts(flags *pflag.FlagSet, hosts *[]string) error { var toRemove []hostMapping if flags.Changed(flagHostRemove) { - extraHostsToRemove := flags.Lookup(flagHostRemove).Value.(*opts.ListOpts).GetAll() + extraHostsToRemove := flags.Lookup(flagHostRemove).Value.(*opts.ListOpts).GetSlice() for _, entry := range extraHostsToRemove { hostName, ipAddr, _ := strings.Cut(entry, ":") toRemove = append(toRemove, hostMapping{IPAddr: ipAddr, Host: hostName}) @@ -1236,7 +1236,7 @@ func updateHosts(flags *pflag.FlagSet, hosts *[]string) error { // Append new hosts (in SwarmKit format) if flags.Changed(flagHostAdd) { - values := convertExtraHostsToSwarmHosts(flags.Lookup(flagHostAdd).Value.(*opts.ListOpts).GetAll()) + values := convertExtraHostsToSwarmHosts(flags.Lookup(flagHostAdd).Value.(*opts.ListOpts).GetSlice()) newHosts = append(newHosts, values...) } *hosts = removeDuplicates(newHosts) @@ -1261,7 +1261,7 @@ func updateLogDriver(flags *pflag.FlagSet, taskTemplate *swarm.TaskSpec) error { taskTemplate.LogDriver = &swarm.Driver{ Name: name, - Options: opts.ConvertKVStringsToMap(flags.Lookup(flagLogOpt).Value.(*opts.ListOpts).GetAll()), + Options: opts.ConvertKVStringsToMap(flags.Lookup(flagLogOpt).Value.(*opts.ListOpts).GetSlice()), } return nil @@ -1470,14 +1470,14 @@ func updateCapabilities(flags *pflag.FlagSet, containerSpec *swarm.ContainerSpec capAdd = opts.CapabilitiesMap(containerSpec.CapabilityAdd) ) if flags.Changed(flagCapAdd) { - toAdd = opts.CapabilitiesMap(flags.Lookup(flagCapAdd).Value.(*opts.ListOpts).GetAll()) + toAdd = opts.CapabilitiesMap(flags.Lookup(flagCapAdd).Value.(*opts.ListOpts).GetSlice()) if toAdd[opts.ResetCapabilities] { capAdd = make(map[string]bool) delete(toAdd, opts.ResetCapabilities) } } if flags.Changed(flagCapDrop) { - toDrop = opts.CapabilitiesMap(flags.Lookup(flagCapDrop).Value.(*opts.ListOpts).GetAll()) + toDrop = opts.CapabilitiesMap(flags.Lookup(flagCapDrop).Value.(*opts.ListOpts).GetSlice()) if toDrop[opts.ResetCapabilities] { capDrop = make(map[string]bool) delete(toDrop, opts.ResetCapabilities) diff --git a/cli/command/trust/signer_add.go b/cli/command/trust/signer_add.go index b4ba0b3998..1553470741 100644 --- a/cli/command/trust/signer_add.go +++ b/cli/command/trust/signer_add.go @@ -59,7 +59,7 @@ func addSigner(ctx context.Context, dockerCLI command.Cli, options signerAddOpti if options.keys.Len() == 0 { return errors.New("path to a public key must be provided using the `--key` flag") } - signerPubKeys, err := ingestPublicKeys(options.keys.GetAll()) + signerPubKeys, err := ingestPublicKeys(options.keys.GetSlice()) if err != nil { return err } diff --git a/cli/command/volume/create.go b/cli/command/volume/create.go index 0e4d035f9a..4092dcd85c 100644 --- a/cli/command/volume/create.go +++ b/cli/command/volume/create.go @@ -117,7 +117,7 @@ func runCreate(ctx context.Context, dockerCli command.Cli, options createOptions Driver: options.driver, DriverOpts: options.driverOpts.GetAll(), Name: options.name, - Labels: opts.ConvertKVStringsToMap(options.labels.GetAll()), + Labels: opts.ConvertKVStringsToMap(options.labels.GetSlice()), } if options.cluster { volOpts.ClusterVolumeSpec = &volume.ClusterVolumeSpec{ @@ -160,7 +160,7 @@ func runCreate(ctx context.Context, dockerCli command.Cli, options createOptions // TODO(dperny): ignore if no topology specified topology := &volume.TopologyRequirement{} - for _, top := range options.requisiteTopology.GetAll() { + for _, top := range options.requisiteTopology.GetSlice() { // each topology takes the form segment=value,segment=value // comma-separated list of equal separated maps segments := map[string]string{} @@ -175,7 +175,7 @@ func runCreate(ctx context.Context, dockerCli command.Cli, options createOptions ) } - for _, top := range options.preferredTopology.GetAll() { + for _, top := range options.preferredTopology.GetSlice() { // each topology takes the form segment=value,segment=value // comma-separated list of equal separated maps segments := map[string]string{}