From 42dbd9306eafa41fcac52106bf8be59949a0c75a Mon Sep 17 00:00:00 2001 From: Sergey Smolnikov Date: Thu, 12 Oct 2023 14:10:02 +0200 Subject: [PATCH] Fixed the error messages --- cmd/setEnvironmentSecret.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/setEnvironmentSecret.go b/cmd/setEnvironmentSecret.go index 935c8bf..7ff1efd 100644 --- a/cmd/setEnvironmentSecret.go +++ b/cmd/setEnvironmentSecret.go @@ -16,6 +16,8 @@ package cmd import ( "errors" + "fmt" + "os" apiclient "github.com/equinor/radix-cli/generated-client/client" "github.com/equinor/radix-cli/generated-client/client/environment" @@ -66,6 +68,10 @@ var setEnvironmentSecretCmd = &cobra.Command{ } component, _ := cmd.Flags().GetString(componentOption) + if component == "" { + return errors.New("`component` is required") + } + awaitReconcile, _ := cmd.Flags().GetBool(awaitReconcileOption) cmd.SilenceUsage = true @@ -81,7 +87,8 @@ var setEnvironmentSecretCmd = &cobra.Command{ }) if !reconciledOk { - return errors.New("component was not reconciled within time") + return fmt.Errorf("component was not reconciled within time: either component %s does not exist in the environment %s or the component has not secret %s", + component, environmentName, secretName) } } @@ -107,6 +114,7 @@ func isComponentSecretReconciled(apiClient *apiclient.Radixapi, appName, environ env, err := apiClient.Environment.GetEnvironment(getEnvironmentParameters, nil) if err != nil { + fmt.Fprintln(os.Stderr, err) return false }