From 9ec27eb227c8f242b915ddfa33ac44bfe88ea654 Mon Sep 17 00:00:00 2001 From: Steven Gagniere Date: Tue, 25 Oct 2022 17:30:03 -0700 Subject: [PATCH 1/2] Modify api-key store error to remove references to the cluster flag --- internal/cmd/api-key/command_store.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/cmd/api-key/command_store.go b/internal/cmd/api-key/command_store.go index d28d3ac53f..d8d3163413 100644 --- a/internal/cmd/api-key/command_store.go +++ b/internal/cmd/api-key/command_store.go @@ -82,7 +82,8 @@ func (c *command) store(cmd *cobra.Command, args []string) error { } else { cluster, err = c.Context.GetKafkaClusterForCommand() if err != nil { - return err + // Replace the error msg since it suggests flags which are unavailable with this command + return errors.NewErrorWithSuggestions(errors.NoKafkaSelectedErrorMsg, errors.APIKeyNotValidForClusterSuggestions) } } From 26cbe33c29af35622fb96b1a573a8916c20630c8 Mon Sep 17 00:00:00 2001 From: Steven Gagniere Date: Tue, 25 Oct 2022 17:59:39 -0700 Subject: [PATCH 2/2] remove --resource from a suggestion string --- internal/pkg/errors/error_message.go | 2 +- test/fixtures/output/kafka/client-config/no-cluster.golden | 2 +- test/fixtures/output/login/err-no-kafka.golden | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/pkg/errors/error_message.go b/internal/pkg/errors/error_message.go index 3073168692..9a0e25ff9c 100644 --- a/internal/pkg/errors/error_message.go +++ b/internal/pkg/errors/error_message.go @@ -402,7 +402,7 @@ const ( KafkaNotReadyErrorMsg = `Kafka cluster "%s" not ready` KafkaNotReadySuggestions = "It may take up to 5 minutes for a recently created Kafka cluster to be ready." NoKafkaSelectedErrorMsg = "no Kafka cluster selected" - NoKafkaSelectedSuggestions = "You must pass `--cluster` or `--resource` with the command or set an active Kafka cluster in your context with `confluent kafka cluster use`." + NoKafkaSelectedSuggestions = "You must pass `--cluster` with the command or set an active Kafka cluster in your context with `confluent kafka cluster use`." NoKafkaForDescribeSuggestions = "You must provide the cluster ID argument or set an active Kafka cluster in your context with `ccloud kafka cluster use`." NoAPISecretStoredErrorMsg = `no API secret for API key "%s" of resource "%s" stored in local CLI state` NoAPISecretStoredSuggestions = "Store the API secret with `confluent api-key store %s --resource %s`." diff --git a/test/fixtures/output/kafka/client-config/no-cluster.golden b/test/fixtures/output/kafka/client-config/no-cluster.golden index 1730daaf75..916bd7ca74 100644 --- a/test/fixtures/output/kafka/client-config/no-cluster.golden +++ b/test/fixtures/output/kafka/client-config/no-cluster.golden @@ -1,4 +1,4 @@ Error: no Kafka cluster selected Suggestions: - You must pass `--cluster` or `--resource` with the command or set an active Kafka cluster in your context with `confluent kafka cluster use`. + You must pass `--cluster` with the command or set an active Kafka cluster in your context with `confluent kafka cluster use`. diff --git a/test/fixtures/output/login/err-no-kafka.golden b/test/fixtures/output/login/err-no-kafka.golden index 1730daaf75..916bd7ca74 100644 --- a/test/fixtures/output/login/err-no-kafka.golden +++ b/test/fixtures/output/login/err-no-kafka.golden @@ -1,4 +1,4 @@ Error: no Kafka cluster selected Suggestions: - You must pass `--cluster` or `--resource` with the command or set an active Kafka cluster in your context with `confluent kafka cluster use`. + You must pass `--cluster` with the command or set an active Kafka cluster in your context with `confluent kafka cluster use`.