Skip to content

Commit

Permalink
Sort config parameters on output
Browse files Browse the repository at this point in the history
fixes #30
  • Loading branch information
ipmb committed Nov 10, 2021
1 parent 9eb1ba9 commit dd2e68d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bridge/ssm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package bridge

import (
"sort"

"github.com/aws/aws-sdk-go/service/ssm"
)

func SortParameters(parameters []*ssm.Parameter) {
sort.Slice(parameters, func(i, j int) bool {
return *parameters[i].Name < *parameters[j].Name
})
}
4 changes: 4 additions & 0 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/aws/aws-sdk-go/service/ssm"

"github.com/apppackio/apppack/app"
"github.com/apppackio/apppack/bridge"
"github.com/logrusorgru/aurora"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -123,6 +124,7 @@ var listCmd = &cobra.Command{
checkErr(err)
parameters, err := a.GetConfig()
checkErr(err)
bridge.SortParameters(parameters)
Spinner.Stop()
for _, value := range parameters {
parts := strings.Split(*value.Name, "/")
Expand All @@ -136,6 +138,7 @@ var listCmd = &cobra.Command{
a.ReviewApp = nil
parameters, err := a.GetConfig()
checkErr(err)
bridge.SortParameters(parameters)
Spinner.Stop()
for _, value := range parameters {
parts := strings.Split(*value.Name, "/")
Expand Down Expand Up @@ -178,6 +181,7 @@ var configExportCmd = &cobra.Command{
a, err := app.Init(AppName, UseAWSCredentials)
checkErr(err)
parameters, err := a.GetConfig()
bridge.SortParameters(parameters)
checkErr(err)
config := make(map[string]string)
ssmSvc := ssm.New(a.Session)
Expand Down

0 comments on commit dd2e68d

Please sign in to comment.