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,20 +524,21 @@ func updateLabels(flags *pflag.FlagSet, field *map[string]string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateEnvironment(flags *pflag.FlagSet, field *[]string) {
|
func updateEnvironment(flags *pflag.FlagSet, field *[]string) {
|
||||||
envSet := map[string]string{}
|
|
||||||
for _, v := range *field {
|
|
||||||
envSet[envKey(v)] = v
|
|
||||||
}
|
|
||||||
if flags.Changed(flagEnvAdd) {
|
if flags.Changed(flagEnvAdd) {
|
||||||
|
envSet := map[string]string{}
|
||||||
|
for _, v := range *field {
|
||||||
|
envSet[envKey(v)] = v
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue