Displaying environment variables in alphanum order for env cmd

Signed-off-by: Matt Farina <matt@mattfarina.com>
pull/6353/head
Matt Farina 5 years ago
parent 378b9dd29e
commit 9191d103ad
No known key found for this signature in database
GPG Key ID: 9436E80BFBA46909

@ -19,6 +19,7 @@ package main
import (
"fmt"
"io"
"sort"
"helm.sh/helm/pkg/cli"
@ -55,8 +56,16 @@ type envOptions struct {
}
func (o *envOptions) run(out io.Writer) error {
for k, v := range o.settings.EnvironmentVariables {
fmt.Printf("%s=\"%s\" \n", k, v)
// Sorting keys to display in alphabetical order
var keys []string
for k := range o.settings.EnvironmentVariables {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
fmt.Printf("%s=\"%s\" \n", k, o.settings.EnvironmentVariables[k])
}
return nil
}

Loading…
Cancel
Save