From 0fbe3a0ceea5176ef77c18760f599840abb252fe Mon Sep 17 00:00:00 2001 From: tmalik <167480759+tmalikconfluent@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:26:12 -0600 Subject: [PATCH 1/9] [CLI-3333] Make email address for SSO case insensitive (#2965) --- pkg/auth/auth_token_handler.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/auth/auth_token_handler.go b/pkg/auth/auth_token_handler.go index 8ed8c85757..a451eb6400 100644 --- a/pkg/auth/auth_token_handler.go +++ b/pkg/auth/auth_token_handler.go @@ -4,6 +4,7 @@ package auth import ( "context" "fmt" + "strings" "time" "github.com/pkg/browser" @@ -230,7 +231,7 @@ func (a *AuthTokenHandlerImpl) checkSSOEmailMatchesLogin(client *ccloudv1.Client if err != nil { return err } - if getMeReply.GetUser().GetEmail() != loginEmail { + if strings.EqualFold(getMeReply.GetUser().GetEmail(), loginEmail) { return errors.NewErrorWithSuggestions( fmt.Sprintf("expected SSO credentials for %s but got credentials for %s", loginEmail, getMeReply.GetUser().GetEmail()), "Please re-login and use the same email at the prompt and in the SSO portal.", From 5bb841dfb1571d3e6567841934aec3649adc4011 Mon Sep 17 00:00:00 2001 From: Panagiotis Garefalakis Date: Sat, 7 Dec 2024 00:34:34 +0200 Subject: [PATCH 2/9] [FRT-838] Pre-Validate environment for artifact commands (#2967) --- internal/flink/command_artifact_create.go | 3 +++ internal/flink/command_artifact_delete.go | 5 +++++ internal/flink/command_artifact_describe.go | 5 +++++ internal/flink/command_artifact_list.go | 5 +++++ 4 files changed, 18 insertions(+) diff --git a/internal/flink/command_artifact_create.go b/internal/flink/command_artifact_create.go index ba97d363aa..12ed5d1404 100644 --- a/internal/flink/command_artifact_create.go +++ b/internal/flink/command_artifact_create.go @@ -95,6 +95,9 @@ func (c *command) createArtifact(cmd *cobra.Command, args []string) error { if err != nil { return err } + if _, err = c.V2Client.GetOrgEnvironment(environment); err != nil { + return fmt.Errorf("environment '%s' not found", environment) + } runtimeLanguage, err := cmd.Flags().GetString("runtime-language") if err != nil { return err diff --git a/internal/flink/command_artifact_delete.go b/internal/flink/command_artifact_delete.go index 676400d91c..558358e866 100644 --- a/internal/flink/command_artifact_delete.go +++ b/internal/flink/command_artifact_delete.go @@ -1,6 +1,8 @@ package flink import ( + "fmt" + "github.com/spf13/cobra" pcmd "github.com/confluentinc/cli/v4/pkg/cmd" @@ -52,6 +54,9 @@ func (c *command) delete(cmd *cobra.Command, args []string) error { if err != nil { return err } + if _, err = c.V2Client.GetOrgEnvironment(environment); err != nil { + return fmt.Errorf("environment '%s' not found", environment) + } existenceFunc := func(id string) bool { artifactIdToName, err := c.mapArtifactIdToName(cloud, region, environment) diff --git a/internal/flink/command_artifact_describe.go b/internal/flink/command_artifact_describe.go index 5c1a9a937d..dcdba4a031 100644 --- a/internal/flink/command_artifact_describe.go +++ b/internal/flink/command_artifact_describe.go @@ -1,6 +1,8 @@ package flink import ( + "fmt" + "github.com/spf13/cobra" pcmd "github.com/confluentinc/cli/v4/pkg/cmd" @@ -48,6 +50,9 @@ func (c *command) describe(cmd *cobra.Command, args []string) error { if err != nil { return err } + if _, err = c.V2Client.GetOrgEnvironment(environment); err != nil { + return fmt.Errorf("environment '%s' not found", environment) + } artifact, err := c.V2Client.DescribeFlinkArtifact(cloud, region, environment, args[0]) if err != nil { diff --git a/internal/flink/command_artifact_list.go b/internal/flink/command_artifact_list.go index 8b39addeb2..3607792958 100644 --- a/internal/flink/command_artifact_list.go +++ b/internal/flink/command_artifact_list.go @@ -1,6 +1,8 @@ package flink import ( + "fmt" + "github.com/spf13/cobra" pcmd "github.com/confluentinc/cli/v4/pkg/cmd" @@ -57,6 +59,9 @@ func (c *command) list(cmd *cobra.Command, _ []string) error { if err != nil { return err } + if _, err = c.V2Client.GetOrgEnvironment(environment); err != nil { + return fmt.Errorf("environment '%s' not found", environment) + } artifacts, err := c.V2Client.ListFlinkArtifacts(cloud, region, environment) if err != nil { From 9bd408976e8d1354739f8317a87e16f31c05b335 Mon Sep 17 00:00:00 2001 From: tmalik <167480759+tmalikconfluent@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:08:51 -0600 Subject: [PATCH 3/9] RCCA-24326 - Confluent CLI SSO login fails for multiple customers (#2969) --- pkg/auth/auth_token_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/auth/auth_token_handler.go b/pkg/auth/auth_token_handler.go index a451eb6400..77c8c78deb 100644 --- a/pkg/auth/auth_token_handler.go +++ b/pkg/auth/auth_token_handler.go @@ -231,7 +231,7 @@ func (a *AuthTokenHandlerImpl) checkSSOEmailMatchesLogin(client *ccloudv1.Client if err != nil { return err } - if strings.EqualFold(getMeReply.GetUser().GetEmail(), loginEmail) { + if !strings.EqualFold(getMeReply.GetUser().GetEmail(), loginEmail) { return errors.NewErrorWithSuggestions( fmt.Sprintf("expected SSO credentials for %s but got credentials for %s", loginEmail, getMeReply.GetUser().GetEmail()), "Please re-login and use the same email at the prompt and in the SSO portal.", From 4c8123a3c08298c8783f55fac0e9f85c5dccaddf Mon Sep 17 00:00:00 2001 From: Steven Gagniere <108363707+sgagniere@users.noreply.github.com> Date: Mon, 9 Dec 2024 11:50:50 -0800 Subject: [PATCH 4/9] [CLI-2969] Prevent double decryption on Windows (#2966) --- pkg/config/api_key_pair.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/config/api_key_pair.go b/pkg/config/api_key_pair.go index ee4b1ca2ec..f81ac294e2 100644 --- a/pkg/config/api_key_pair.go +++ b/pkg/config/api_key_pair.go @@ -1,7 +1,6 @@ package config import ( - "runtime" "strings" "github.com/confluentinc/cli/v4/pkg/secret" @@ -16,7 +15,7 @@ type APIKeyPair struct { } func (c *APIKeyPair) DecryptSecret() error { - if (strings.HasPrefix(c.Secret, secret.AesGcm) && c.Salt != nil) || runtime.GOOS == "windows" { + if (strings.HasPrefix(c.Secret, secret.AesGcm) && c.Salt != nil) || strings.HasPrefix(c.Secret, secret.Dpapi) { decryptedSecret, err := secret.Decrypt(c.Key, c.Secret, c.Salt, c.Nonce) if err != nil { return err From 30af943e2829865819f323afb7963dd5fd31d299 Mon Sep 17 00:00:00 2001 From: Steven Gagniere <108363707+sgagniere@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:58:27 -0800 Subject: [PATCH 5/9] [CLI-3272] Add panic stack trace to `-vvvv` output for non-Cloud users (#2963) --- internal/command.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/command.go b/internal/command.go index bca0c88473..6917152d7f 100644 --- a/internal/command.go +++ b/internal/command.go @@ -3,6 +3,7 @@ package internal import ( "fmt" "os" + "runtime/debug" "strings" shell "github.com/brianstrauch/cobra-shell" @@ -54,6 +55,7 @@ import ( "github.com/confluentinc/cli/v4/pkg/form" "github.com/confluentinc/cli/v4/pkg/help" "github.com/confluentinc/cli/v4/pkg/jwt" + "github.com/confluentinc/cli/v4/pkg/log" "github.com/confluentinc/cli/v4/pkg/output" ppanic "github.com/confluentinc/cli/v4/pkg/panic-recovery" pplugin "github.com/confluentinc/cli/v4/pkg/plugin" @@ -151,8 +153,8 @@ func NewConfluentCommand(cfg *config.Config) *cobra.Command { func Execute(cmd *cobra.Command, args []string, cfg *config.Config) error { defer func() { if r := recover(); r != nil { - if !cfg.Version.IsReleased() { - panic(r) + if !cfg.IsCloudLogin() || cfg.HasGovHostname() || !cfg.Version.IsReleased() { + log.CliLogger.Trace(string(debug.Stack())) } u := ppanic.CollectPanic(cmd, args, cfg) if err := reportUsage(cmd, cfg, u); err != nil { From 86b6e21c00687f765cdba373a32f6e1ad3f900fc Mon Sep 17 00:00:00 2001 From: Hao Li <1127478+lihaosky@users.noreply.github.com> Date: Thu, 12 Dec 2024 22:40:24 -0800 Subject: [PATCH 6/9] Check environment for connection commands --- internal/flink/command_connection_create.go | 2 +- internal/flink/command_connection_delete.go | 6 ++++++ internal/flink/command_connection_describe.go | 7 +++++++ internal/flink/command_connection_list.go | 5 +++++ internal/flink/command_connection_update.go | 6 ++++++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/internal/flink/command_connection_create.go b/internal/flink/command_connection_create.go index 174c211c85..b6b794f752 100644 --- a/internal/flink/command_connection_create.go +++ b/internal/flink/command_connection_create.go @@ -79,7 +79,7 @@ func (c *command) connectionCreate(cmd *cobra.Command, args []string) error { } if _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil { - return errors.NewErrorWithSuggestions(err.Error(), "List available environments with `confluent environment list`.") + return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf("Failed to get environment '%s'. List available environments with `confluent environment list`.", environmentId)) } client, err := c.GetFlinkGatewayClient(false) diff --git a/internal/flink/command_connection_delete.go b/internal/flink/command_connection_delete.go index 572a10ae88..77f79b7cf2 100644 --- a/internal/flink/command_connection_delete.go +++ b/internal/flink/command_connection_delete.go @@ -1,10 +1,12 @@ package flink import ( + "fmt" "github.com/spf13/cobra" pcmd "github.com/confluentinc/cli/v4/pkg/cmd" "github.com/confluentinc/cli/v4/pkg/deletion" + "github.com/confluentinc/cli/v4/pkg/errors" "github.com/confluentinc/cli/v4/pkg/resource" ) @@ -35,6 +37,10 @@ func (c *command) connectionDelete(cmd *cobra.Command, args []string) error { return err } + if _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil { + return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf("Failed to get environment '%s'. List available environments with `confluent environment list`.", environmentId)) + } + client, err := c.GetFlinkGatewayClient(false) if err != nil { return err diff --git a/internal/flink/command_connection_describe.go b/internal/flink/command_connection_describe.go index 330a13853f..251009f2f7 100644 --- a/internal/flink/command_connection_describe.go +++ b/internal/flink/command_connection_describe.go @@ -1,9 +1,12 @@ package flink import ( + "fmt" + "github.com/spf13/cobra" pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/errors" "github.com/confluentinc/cli/v4/pkg/output" ) @@ -33,6 +36,10 @@ func (c *command) connectionDescribe(cmd *cobra.Command, args []string) error { return err } + if _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil { + return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf("Failed to get environment '%s'. List available environments with `confluent environment list`.", environmentId)) + } + client, err := c.GetFlinkGatewayClient(false) if err != nil { return err diff --git a/internal/flink/command_connection_list.go b/internal/flink/command_connection_list.go index 3451d051df..a627848413 100644 --- a/internal/flink/command_connection_list.go +++ b/internal/flink/command_connection_list.go @@ -7,6 +7,7 @@ import ( "github.com/spf13/cobra" pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/errors" "github.com/confluentinc/cli/v4/pkg/flink" "github.com/confluentinc/cli/v4/pkg/output" "github.com/confluentinc/cli/v4/pkg/utils" @@ -43,6 +44,10 @@ func (c *command) connectionList(cmd *cobra.Command, _ []string) error { return err } + if _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil { + return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf("Failed to get environment '%s'. List available environments with `confluent environment list`.", environmentId)) + } + connectionType, err := cmd.Flags().GetString("type") if err != nil { return err diff --git a/internal/flink/command_connection_update.go b/internal/flink/command_connection_update.go index 9a872afd88..e28d1b76ef 100644 --- a/internal/flink/command_connection_update.go +++ b/internal/flink/command_connection_update.go @@ -2,6 +2,7 @@ package flink import ( "encoding/json" + "fmt" "strings" "github.com/spf13/cobra" @@ -9,6 +10,7 @@ import ( flinkgatewayv1 "github.com/confluentinc/ccloud-sdk-go-v2/flink-gateway/v1" pcmd "github.com/confluentinc/cli/v4/pkg/cmd" + "github.com/confluentinc/cli/v4/pkg/errors" "github.com/confluentinc/cli/v4/pkg/examples" "github.com/confluentinc/cli/v4/pkg/output" ) @@ -46,6 +48,10 @@ func (c *command) connectionUpdate(cmd *cobra.Command, args []string) error { return err } + if _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil { + return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf("Failed to get environment '%s'. List available environments with `confluent environment list`.", environmentId)) + } + client, err := c.GetFlinkGatewayClient(false) if err != nil { return err From 18dc23a16e8df2b5d5faf9baa49c0334878a7129 Mon Sep 17 00:00:00 2001 From: Hao Li <1127478+lihaosky@users.noreply.github.com> Date: Thu, 12 Dec 2024 23:04:00 -0800 Subject: [PATCH 7/9] tests --- .../connection/create/create-wrong-env.golden | 4 ++++ .../connection/delete/delete-wrong-env.golden | 4 ++++ .../connection/describe/describe-wrong-env.golden | 4 ++++ .../flink/connection/list/list-wrong-env.golden | 4 ++++ .../connection/update/update-wrong-env.golden | 4 ++++ test/flink_test.go | 15 +++++++++++++++ 6 files changed, 35 insertions(+) create mode 100644 test/fixtures/output/flink/connection/create/create-wrong-env.golden create mode 100644 test/fixtures/output/flink/connection/delete/delete-wrong-env.golden create mode 100644 test/fixtures/output/flink/connection/describe/describe-wrong-env.golden create mode 100644 test/fixtures/output/flink/connection/list/list-wrong-env.golden create mode 100644 test/fixtures/output/flink/connection/update/update-wrong-env.golden diff --git a/test/fixtures/output/flink/connection/create/create-wrong-env.golden b/test/fixtures/output/flink/connection/create/create-wrong-env.golden new file mode 100644 index 0000000000..6673a16a5a --- /dev/null +++ b/test/fixtures/output/flink/connection/create/create-wrong-env.golden @@ -0,0 +1,4 @@ +Error: 404 Not Found + +Suggestions: + Failed to get environment 'env-dne'. List available environments with `confluent environment list`. diff --git a/test/fixtures/output/flink/connection/delete/delete-wrong-env.golden b/test/fixtures/output/flink/connection/delete/delete-wrong-env.golden new file mode 100644 index 0000000000..6673a16a5a --- /dev/null +++ b/test/fixtures/output/flink/connection/delete/delete-wrong-env.golden @@ -0,0 +1,4 @@ +Error: 404 Not Found + +Suggestions: + Failed to get environment 'env-dne'. List available environments with `confluent environment list`. diff --git a/test/fixtures/output/flink/connection/describe/describe-wrong-env.golden b/test/fixtures/output/flink/connection/describe/describe-wrong-env.golden new file mode 100644 index 0000000000..6673a16a5a --- /dev/null +++ b/test/fixtures/output/flink/connection/describe/describe-wrong-env.golden @@ -0,0 +1,4 @@ +Error: 404 Not Found + +Suggestions: + Failed to get environment 'env-dne'. List available environments with `confluent environment list`. diff --git a/test/fixtures/output/flink/connection/list/list-wrong-env.golden b/test/fixtures/output/flink/connection/list/list-wrong-env.golden new file mode 100644 index 0000000000..6673a16a5a --- /dev/null +++ b/test/fixtures/output/flink/connection/list/list-wrong-env.golden @@ -0,0 +1,4 @@ +Error: 404 Not Found + +Suggestions: + Failed to get environment 'env-dne'. List available environments with `confluent environment list`. diff --git a/test/fixtures/output/flink/connection/update/update-wrong-env.golden b/test/fixtures/output/flink/connection/update/update-wrong-env.golden new file mode 100644 index 0000000000..6673a16a5a --- /dev/null +++ b/test/fixtures/output/flink/connection/update/update-wrong-env.golden @@ -0,0 +1,4 @@ +Error: 404 Not Found + +Suggestions: + Failed to get environment 'env-dne'. List available environments with `confluent environment list`. diff --git a/test/flink_test.go b/test/flink_test.go index 888b3cab4b..8ff658bf0e 100644 --- a/test/flink_test.go +++ b/test/flink_test.go @@ -85,6 +85,21 @@ func (s *CLITestSuite) TestFlinkConnection() { } } +func (s *CLITestSuite) TestFlinkConnectionWrongEnv() { + tests := []CLITest{ + {args: "flink connection create my-connection --cloud aws --region eu-west-1 --type openai --endpoint https://api.openai.com/v1/chat/completions --api-key 0000000000000000 --environment env-dne", fixture: "flink/connection/create/create-wrong-env.golden", exitCode: 1}, + {args: "flink connection describe my-connection --cloud aws --region eu-west-1 --environment env-dne", fixture: "flink/connection/describe/describe-wrong-env.golden", exitCode: 1}, + {args: "flink connection list --cloud aws --region eu-west-1 --environment env-dne", fixture: "flink/connection/list/list-wrong-env.golden", exitCode: 1}, + {args: "flink connection update my-connection --cloud aws --region eu-west-1 --api-key 0000000000000000 --environment env-dne", fixture: "flink/connection/update/update-wrong-env.golden", exitCode: 1}, + {args: "flink connection delete my-connection --force --cloud aws --region eu-west-1 --environment env-dne", fixture: "flink/connection/delete/delete-wrong-env.golden", exitCode: 1}, + } + + for _, test := range tests { + test.login = "cloud" + s.runIntegrationTest(test) + } +} + func (s *CLITestSuite) TestFlinkConnectionDelete() { tests := []CLITest{ {args: "flink connection delete my-connection --force --cloud aws --region eu-west-1", fixture: "flink/connection/delete/delete.golden"}, From 91abb2333eddeee9f9e100f6b3e22c70ba3c4cd3 Mon Sep 17 00:00:00 2001 From: Hao Li <1127478+lihaosky@users.noreply.github.com> Date: Fri, 13 Dec 2024 09:29:55 -0800 Subject: [PATCH 8/9] lint --- internal/flink/command_connection_delete.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/flink/command_connection_delete.go b/internal/flink/command_connection_delete.go index 77f79b7cf2..2b24d07bc6 100644 --- a/internal/flink/command_connection_delete.go +++ b/internal/flink/command_connection_delete.go @@ -2,6 +2,7 @@ package flink import ( "fmt" + "github.com/spf13/cobra" pcmd "github.com/confluentinc/cli/v4/pkg/cmd" From 4398f0c44b58d3a4e94350f42edf832df9f75eaf Mon Sep 17 00:00:00 2001 From: Hao Li <1127478+lihaosky@users.noreply.github.com> Date: Fri, 13 Dec 2024 10:39:23 -0800 Subject: [PATCH 9/9] comment --- internal/flink/command_connection.go | 2 ++ internal/flink/command_connection_create.go | 2 +- internal/flink/command_connection_delete.go | 2 +- internal/flink/command_connection_describe.go | 2 +- internal/flink/command_connection_list.go | 2 +- internal/flink/command_connection_update.go | 2 +- 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/flink/command_connection.go b/internal/flink/command_connection.go index 932c56ad86..cb12a51875 100644 --- a/internal/flink/command_connection.go +++ b/internal/flink/command_connection.go @@ -13,6 +13,8 @@ import ( "github.com/confluentinc/cli/v4/pkg/utils" ) +const envNotFoundErrorMsg = "Failed to get environment '%s'. List available environments with `confluent environment list`." + type connectionOut struct { CreationDate time.Time `human:"Creation Date" serialized:"creation_date"` Name string `human:"Name" serialized:"name"` diff --git a/internal/flink/command_connection_create.go b/internal/flink/command_connection_create.go index b6b794f752..9ffc290735 100644 --- a/internal/flink/command_connection_create.go +++ b/internal/flink/command_connection_create.go @@ -79,7 +79,7 @@ func (c *command) connectionCreate(cmd *cobra.Command, args []string) error { } if _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil { - return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf("Failed to get environment '%s'. List available environments with `confluent environment list`.", environmentId)) + return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf(envNotFoundErrorMsg, environmentId)) } client, err := c.GetFlinkGatewayClient(false) diff --git a/internal/flink/command_connection_delete.go b/internal/flink/command_connection_delete.go index 2b24d07bc6..b46d11308b 100644 --- a/internal/flink/command_connection_delete.go +++ b/internal/flink/command_connection_delete.go @@ -39,7 +39,7 @@ func (c *command) connectionDelete(cmd *cobra.Command, args []string) error { } if _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil { - return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf("Failed to get environment '%s'. List available environments with `confluent environment list`.", environmentId)) + return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf(envNotFoundErrorMsg, environmentId)) } client, err := c.GetFlinkGatewayClient(false) diff --git a/internal/flink/command_connection_describe.go b/internal/flink/command_connection_describe.go index 251009f2f7..97e0e93cac 100644 --- a/internal/flink/command_connection_describe.go +++ b/internal/flink/command_connection_describe.go @@ -37,7 +37,7 @@ func (c *command) connectionDescribe(cmd *cobra.Command, args []string) error { } if _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil { - return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf("Failed to get environment '%s'. List available environments with `confluent environment list`.", environmentId)) + return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf(envNotFoundErrorMsg, environmentId)) } client, err := c.GetFlinkGatewayClient(false) diff --git a/internal/flink/command_connection_list.go b/internal/flink/command_connection_list.go index a627848413..15ef59709a 100644 --- a/internal/flink/command_connection_list.go +++ b/internal/flink/command_connection_list.go @@ -45,7 +45,7 @@ func (c *command) connectionList(cmd *cobra.Command, _ []string) error { } if _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil { - return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf("Failed to get environment '%s'. List available environments with `confluent environment list`.", environmentId)) + return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf(envNotFoundErrorMsg, environmentId)) } connectionType, err := cmd.Flags().GetString("type") diff --git a/internal/flink/command_connection_update.go b/internal/flink/command_connection_update.go index e28d1b76ef..7897d98bc4 100644 --- a/internal/flink/command_connection_update.go +++ b/internal/flink/command_connection_update.go @@ -49,7 +49,7 @@ func (c *command) connectionUpdate(cmd *cobra.Command, args []string) error { } if _, err := c.V2Client.GetOrgEnvironment(environmentId); err != nil { - return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf("Failed to get environment '%s'. List available environments with `confluent environment list`.", environmentId)) + return errors.NewErrorWithSuggestions(err.Error(), fmt.Sprintf(envNotFoundErrorMsg, environmentId)) } client, err := c.GetFlinkGatewayClient(false)