From 2fdf218c7da917e7faf0d7fd558303b7aa8bd31b Mon Sep 17 00:00:00 2001 From: Grant Linville Date: Thu, 18 Jan 2024 09:49:25 -0500 Subject: [PATCH] fix: credential secrets: handle case where no default is set (#2423) Signed-off-by: Grant Linville --- pkg/login/login.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/login/login.go b/pkg/login/login.go index 132061494..755b1ab67 100644 --- a/pkg/login/login.go +++ b/pkg/login/login.go @@ -107,7 +107,11 @@ func createSecret(ctx context.Context, c client.Client, app *apiv1.App, secretNa promptOrder, _ := app.Status.AppSpec.Secrets[secretName].Params.GetData()["promptOrder"].([]string) for _, key := range promptOrder { if def, ok := app.Status.AppSpec.Secrets[secretName].Data[key]; ok { - value, err := prompt.Password(fmt.Sprintf("%s (default: %s)", key, def)) + message := key + if def != "" { + message += fmt.Sprintf(" (default: %s)", def) + } + value, err := prompt.Password(message) if err != nil { return err } @@ -123,7 +127,11 @@ func createSecret(ctx context.Context, c client.Client, app *apiv1.App, secretNa continue } def := app.Status.AppSpec.Secrets[secretName].Data[key] - value, err := prompt.Password(fmt.Sprintf("%s (default: %s)", key, def)) + message := key + if def != "" { + message += fmt.Sprintf(" (default: %s)", def) + } + value, err := prompt.Password(message) if err != nil { return err }