From 161513092999d9ee213176d12696300a7e7bb93c Mon Sep 17 00:00:00 2001 From: decentral1se Date: Tue, 15 Mar 2022 10:54:05 +0100 Subject: [PATCH] fix: skip prompt for no passwords --- cli/internal/new.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cli/internal/new.go b/cli/internal/new.go index 9f479b8f9..032647a6c 100644 --- a/cli/internal/new.go +++ b/cli/internal/new.go @@ -4,6 +4,7 @@ import ( "fmt" "path" + "coopcloud.tech/abra/pkg/app" "coopcloud.tech/abra/pkg/config" "coopcloud.tech/abra/pkg/formatter" "coopcloud.tech/abra/pkg/recipe" @@ -67,7 +68,18 @@ func ensureDomainFlag(recipe recipe.Recipe, server string) error { } // promptForSecrets asks if we should generate secrets for a new app. -func promptForSecrets() error { +func promptForSecrets(appName string) error { + app, err := app.Get(appName) + if err != nil { + return err + } + + secretEnvVars := secret.ReadSecretEnvVars(app.Env) + if len(secretEnvVars) == 0 { + logrus.Debugf("%s has no secrets to generate, skipping...", app.Recipe) + return nil + } + if !Secrets && !NoInput { prompt := &survey.Confirm{ Message: "Generate app secrets?", @@ -120,7 +132,7 @@ func NewAction(c *cli.Context) error { logrus.Fatal(err) } - if err := promptForSecrets(); err != nil { + if err := promptForSecrets(Domain); err != nil { logrus.Fatal(err) }