Skip to content

Commit de0a88e

Browse files
nan-yusdowell
andauthored
fix: enable user output for version list (#1084) (#1134)
Suppressing the user output also disabled output for the happy path where a version exists. This reverts the behavior back to how it was before with an error check on the output. Co-authored-by: Sam Dowell <sdowell@google.com>
1 parent 73e7277 commit de0a88e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

e2e/testcases/helm_sync_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"os"
2222
"path/filepath"
23+
"strconv"
2324
"strings"
2425
"sync"
2526
"testing"
@@ -853,7 +854,6 @@ func fetchServiceAccountKeyFile(nt *nomostest.NT, projectID, gsaKeySecretID, gsa
853854
out, err := nt.Shell.ExecWithDebug("gcloud", "secrets", "versions", "list",
854855
gsaKeySecretID,
855856
"--filter", "state=ENABLED",
856-
"--no-user-output-enabled", // suppress warning messages that interfere with parsing
857857
"--limit", "1",
858858
"--format", "value(name)",
859859
"--project", projectID)
@@ -878,14 +878,17 @@ func fetchServiceAccountKeyFile(nt *nomostest.NT, projectID, gsaKeySecretID, gsa
878878
// even tho in json the "name" field is the full name.
879879
// But what the access command wants is the version. So it's fine.
880880
gsaKeySecretVersion := strings.TrimSpace(string(out))
881-
if gsaKeySecretVersion == "" {
881+
if gsaKeySecretVersion == "" || strings.HasPrefix(gsaKeySecretVersion, "WARNING: ") {
882882
nt.T.Log("No enabled secrets versions")
883883
err = generateServiceAccountKey(nt, projectID, gsaKeySecretID, gsaEmail, gsaKeyFilePath)
884884
if err != nil {
885885
return "", err
886886
}
887887
return gsaKeyFilePath, nil
888888
}
889+
if _, err := strconv.Atoi(gsaKeySecretVersion); err != nil {
890+
return "", fmt.Errorf("converting version to int: %w", err)
891+
}
889892

890893
nt.T.Log("Reading service account key from Secret Manager")
891894
_, err = nt.Shell.ExecWithDebug("gcloud", "secrets", "versions",

0 commit comments

Comments
 (0)