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 <github@gone.nl>
This commit is contained in:
parent
81a5db6b82
commit
22a573649d
@ -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,
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -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,
|
||||
},
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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{}
|
||||
|
Loading…
x
Reference in New Issue
Block a user