Make get-management-config print in order
This causes the `airshipctl config get-management-config` command to print all management configurations in order. This fixes an issue where unit tests would randomly fail, since the output order from the command was not consistent. Change-Id: I83da272d56b90026dac8c07d7522119500935406
This commit is contained in:
parent
eb7ae187f5
commit
3f79bf8bbd
@ -16,6 +16,7 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@ -58,7 +59,15 @@ func NewGetManagementConfigCommand(rootSettings *environment.AirshipCTLSettings)
|
||||
return nil
|
||||
}
|
||||
|
||||
for key, config := range rootSettings.Config.ManagementConfiguration {
|
||||
// Print all of the management configurations in order by name
|
||||
keys := make([]string, 0, len(rootSettings.Config.ManagementConfiguration))
|
||||
for key := range rootSettings.Config.ManagementConfiguration {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
for _, key := range keys {
|
||||
config := rootSettings.Config.ManagementConfiguration[key]
|
||||
fmt.Fprintf(cmd.OutOrStdout(), "name: %s\n%s\n", key, config.String())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user