Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
fix: credential secrets: use defaults as defined in the Acornfile (#2420
Browse files Browse the repository at this point in the history
)

Signed-off-by: Grant Linville <grant@acorn.io>
  • Loading branch information
g-linville authored Jan 17, 2024
1 parent 002f6b5 commit 70b569f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,14 @@ func createSecret(ctx context.Context, c client.Client, app *apiv1.App, secretNa
data := map[string][]byte{}
promptOrder, _ := app.Status.AppSpec.Secrets[secretName].Params.GetData()["promptOrder"].([]string)
for _, key := range promptOrder {
if _, ok := app.Status.AppSpec.Secrets[secretName].Data[key]; ok {
value, err := prompt.Password(key)
if def, ok := app.Status.AppSpec.Secrets[secretName].Data[key]; ok {
value, err := prompt.Password(fmt.Sprintf("%s (default: %s)", key, def))
if err != nil {
return err
}
if len(value) == 0 {
value = []byte(def)
}
data[key] = value
asked[key] = struct{}{}
}
Expand All @@ -119,10 +122,14 @@ func createSecret(ctx context.Context, c client.Client, app *apiv1.App, secretNa
if _, asked := asked[key]; asked {
continue
}
value, err := prompt.Password(key)
def := app.Status.AppSpec.Secrets[secretName].Data[key]
value, err := prompt.Password(fmt.Sprintf("%s (default: %s)", key, def))
if err != nil {
return err
}
if len(value) == 0 {
value = []byte(def)
}
data[key] = value
}

Expand Down

0 comments on commit 70b569f

Please sign in to comment.