mirror of https://github.com/docker/cli.git
cli/compose/convert: convertEnvironment: sort results
All users of this function sorted the results afterwards, so let's do it as part of the function itself. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
f4bde68694
commit
d68b361538
|
@ -133,7 +133,7 @@ func Service(
|
|||
Hosts: convertExtraHosts(service.ExtraHosts),
|
||||
DNSConfig: dnsConfig,
|
||||
Healthcheck: healthcheck,
|
||||
Env: sortStrings(convertEnvironment(service.Environment)),
|
||||
Env: convertEnvironment(service.Environment),
|
||||
Labels: AddStackLabel(namespace, service.Labels),
|
||||
Dir: service.WorkingDir,
|
||||
User: service.User,
|
||||
|
@ -199,11 +199,6 @@ func getPlacementPreference(preferences []composetypes.PlacementPreferences) []s
|
|||
return result
|
||||
}
|
||||
|
||||
func sortStrings(strs []string) []string {
|
||||
sort.Strings(strs)
|
||||
return strs
|
||||
}
|
||||
|
||||
func convertServiceNetworks(
|
||||
networks map[string]*composetypes.ServiceNetworkConfig,
|
||||
networkConfigs networkMap,
|
||||
|
@ -596,6 +591,8 @@ func convertEndpointSpec(endpointMode string, source []composetypes.ServicePortC
|
|||
}
|
||||
}
|
||||
|
||||
// convertEnvironment converts key/value mappings to a slice, and sorts
|
||||
// the results.
|
||||
func convertEnvironment(source map[string]*string) []string {
|
||||
var output []string
|
||||
|
||||
|
@ -607,7 +604,7 @@ func convertEnvironment(source map[string]*string) []string {
|
|||
output = append(output, name+"="+*value)
|
||||
}
|
||||
}
|
||||
|
||||
sort.Strings(output)
|
||||
return output
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package convert
|
|||
import (
|
||||
"context"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -59,7 +58,6 @@ func TestConvertEnvironment(t *testing.T) {
|
|||
"key": strPtr("value"),
|
||||
}
|
||||
env := convertEnvironment(source)
|
||||
sort.Strings(env)
|
||||
assert.Check(t, is.DeepEqual([]string{"foo=bar", "key=value"}, env))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue