From c9e293bde26154f7c2be206d924a32c59323e91e Mon Sep 17 00:00:00 2001 From: p4u1 Date: Mon, 25 Aug 2025 12:54:20 +0200 Subject: [PATCH] feat(secrets): Sort list output This is usefull for scripting. --- cli/app/secret.go | 5 +++++ tests/integration/app_secret.bats | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/cli/app/secret.go b/cli/app/secret.go index d1ef0b29..0cd18874 100644 --- a/cli/app/secret.go +++ b/cli/app/secret.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "os" + "sort" "strconv" "strings" @@ -435,6 +436,10 @@ var AppSecretLsCommand = &cobra.Command{ log.Fatal(err) } + // Sort secrets to ensure reproducible output + sort.Slice(secStats, func(i, j int) bool { + return secStats[i].LocalName < secStats[j].LocalName + }) var rows [][]string for _, secStat := range secStats { row := []string{ diff --git a/tests/integration/app_secret.bats b/tests/integration/app_secret.bats index a009c33c..17ae926c 100644 --- a/tests/integration/app_secret.bats +++ b/tests/integration/app_secret.bats @@ -357,6 +357,12 @@ teardown(){ | jq -r ".[] | select(.name==\"test_pass_two\") | .version"' assert_success assert_output --partial 'v1' + + # Can always expect the secret at this position + run bash -c '$ABRA app secret ls "$TEST_APP_DOMAIN" --machine \ + | jq -r ".[1] | .name"' + assert_success + assert_output --partial 'test_pass_two' } @test "ls: bail if unstaged changes and no --chaos" {