diff --git a/config/commands.go b/config/commands.go index 5b8fd3309..64504939f 100644 --- a/config/commands.go +++ b/config/commands.go @@ -3,6 +3,7 @@ package config import ( "fmt" "os" + "sort" "strings" "github.com/pkg/errors" @@ -10,9 +11,19 @@ import ( ) func printValues(values Values) { - for key, value := range values { - fmt.Fprintf(os.Stderr, "%-18s %s\n", key+":", value) + // Provide a stable sort order for printed values + keys := make([]string, 0, len(values)) + for k := range values { + keys = append(keys, k) } + sort.Strings(keys) + + for _, key := range keys { + fmt.Fprintf(os.Stderr, "%-18s %v\n", key+":", values[key]) + } + + // Add empty newline at end + fmt.Fprintf(os.Stderr, "\n") } type ProcessConfigOpts struct { @@ -73,7 +84,7 @@ func (c *ConfigCompiler) ProcessConfig(opts ProcessConfigOpts) error { //if no orgId provided use org slug values := LocalPipelineValues() if opts.VerboseOutput { - fmt.Println("Processing config with following values") + fmt.Fprintln(os.Stderr, "Processing config with following values:") printValues(values) } @@ -118,7 +129,7 @@ func (c *ConfigCompiler) ValidateConfig(opts ValidateConfigOpts) error { //if no orgId provided use org slug values := LocalPipelineValues() if opts.VerboseOutput { - fmt.Println("Validating config with following values") + fmt.Fprintln(os.Stderr, "Validating config with following values:") printValues(values) } @@ -152,6 +163,6 @@ func (c *ConfigCompiler) ValidateConfig(opts ValidateConfigOpts) error { } } - fmt.Printf("\nConfig file at %s is valid.\n", opts.ConfigPath) + fmt.Printf("Config file at %s is valid.\n", opts.ConfigPath) return nil }