mirror of https://github.com/docker/cli.git
Merge pull request #32364 from aaronlehmann/preserve-env-order
cli: Preserve order of environment variables
This commit is contained in:
commit
fbddea6cac
|
@ -524,21 +524,22 @@ func updateLabels(flags *pflag.FlagSet, field *map[string]string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateEnvironment(flags *pflag.FlagSet, field *[]string) {
|
func updateEnvironment(flags *pflag.FlagSet, field *[]string) {
|
||||||
|
if flags.Changed(flagEnvAdd) {
|
||||||
envSet := map[string]string{}
|
envSet := map[string]string{}
|
||||||
for _, v := range *field {
|
for _, v := range *field {
|
||||||
envSet[envKey(v)] = v
|
envSet[envKey(v)] = v
|
||||||
}
|
}
|
||||||
if flags.Changed(flagEnvAdd) {
|
|
||||||
value := flags.Lookup(flagEnvAdd).Value.(*opts.ListOpts)
|
value := flags.Lookup(flagEnvAdd).Value.(*opts.ListOpts)
|
||||||
for _, v := range value.GetAll() {
|
for _, v := range value.GetAll() {
|
||||||
envSet[envKey(v)] = v
|
envSet[envKey(v)] = v
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
*field = []string{}
|
*field = []string{}
|
||||||
for _, v := range envSet {
|
for _, v := range envSet {
|
||||||
*field = append(*field, v)
|
*field = append(*field, v)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toRemove := buildToRemoveSet(flags, flagEnvRemove)
|
toRemove := buildToRemoveSet(flags, flagEnvRemove)
|
||||||
*field = removeItems(*field, toRemove, envKey)
|
*field = removeItems(*field, toRemove, envKey)
|
||||||
|
|
Loading…
Reference in New Issue