Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
5569d8a
modified grammar and capitalized Kafka REST for string RestProxyNotAv…
sgagniere Aug 2, 2022
d5a533f
Some typo fixes in error_message.go, as well as some changes to capit…
sgagniere Aug 3, 2022
97e1eea
Test updates for the last set of string updates
sgagniere Aug 3, 2022
135300a
Changed suffixes of some string vars in error_message.go from Msg to …
sgagniere Aug 3, 2022
5892351
Updated golden file
sgagniere Aug 3, 2022
23baa00
added missing var suffix to an error message
sgagniere Aug 3, 2022
b5a6d70
Simplified a call to one of the error messages
sgagniere Aug 3, 2022
a3056b0
Renamed a few more error message variables
sgagniere Aug 3, 2022
66ab2b0
Removed some unused strings from error_message.go
sgagniere Aug 4, 2022
268bda8
Removed more unused strings from error_message.go
sgagniere Aug 9, 2022
cd2220f
Added missing 's' to var name of various Suggestions
sgagniere Aug 9, 2022
88b816d
Removed newlines from the last sentence of a few suggestions and upda…
sgagniere Aug 9, 2022
383082d
Modified suggestions w/ urls at the end to have a space before a peri…
sgagniere Aug 9, 2022
46c9fe9
ran go fmt on error_message.go
sgagniere Aug 9, 2022
dbb1e1e
Added Msg suffix to a message in strings.go
sgagniere Aug 9, 2022
7acfd85
Changed a few multi-sentence error messages to a single sentence w/ a…
sgagniere Aug 9, 2022
759c7a1
Merge branch 'main' of github.com:confluentinc/cli into string-updates
sgagniere Aug 9, 2022
5f3aa23
Changed a string to use double quotes instead of backticks to match t…
sgagniere Aug 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/cmd/kafka/command_acl_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (c *aclCommand) create(cmd *cobra.Command, _ []string) error {
_ = aclutil.PrintACLsWithResourceIdMap(cmd, bindings[:i], os.Stdout, resourceIdMap)
}
return errors.NewErrorWithSuggestions(
fmt.Sprintf(errors.KafkaRestUnexpectedStatusMsg, httpResp.Request.URL, httpResp.StatusCode),
fmt.Sprintf(errors.KafkaRestUnexpectedStatusErrorMsg, httpResp.Request.URL, httpResp.StatusCode),
errors.InternalServerErrorSuggestions)
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/kafka/command_acl_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (c *aclCommand) delete(cmd *cobra.Command, _ []string) error {
} else {
printAclsDeleted(cmd, matchingBindingCount)
return errors.NewErrorWithSuggestions(
fmt.Sprintf(errors.KafkaRestUnexpectedStatusMsg, httpResp.Request.URL, httpResp.StatusCode),
fmt.Sprintf(errors.KafkaRestUnexpectedStatusErrorMsg, httpResp.Request.URL, httpResp.StatusCode),
errors.InternalServerErrorSuggestions)
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/kafka/command_acl_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (c *aclCommand) list(cmd *cobra.Command, _ []string) error {
if err == nil && httpResp != nil {
if httpResp.StatusCode != http.StatusOK {
return errors.NewErrorWithSuggestions(
fmt.Sprintf(errors.KafkaRestUnexpectedStatusMsg, httpResp.Request.URL, httpResp.StatusCode),
fmt.Sprintf(errors.KafkaRestUnexpectedStatusErrorMsg, httpResp.Request.URL, httpResp.StatusCode),
errors.InternalServerErrorSuggestions)
}
// Kafka REST is available and there was no error
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/kafka/command_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (suite *KafkaClusterTestSuite) TestClusterShrinkShouldPrompt() {
cmd := suite.newCmd(v1.AuthenticatedCloudConfigMock())
cmd.SetArgs([]string{"update", clusterName, "--cku", "2"})
err := cmd.Execute()
req.Contains(err.Error(), "Cluster resize error: failed to read your confirmation")
req.Contains(err.Error(), "cluster resize error: failed to read your confirmation")
req.True(suite.metricsApi.V2MetricsDatasetQueryPostCalled())
req.True(suite.metricsApi.V2MetricsDatasetQueryPostExecuteCalled())
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/kafka/command_cluster_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (c *clusterCommand) validateResize(cmd *cobra.Command, currentCluster *cmkv
}
// Ensure the cluster is a Dedicated Cluster
if currentCluster.GetSpec().Config.CmkV2Dedicated == nil {
return -1, errors.Errorf("failed to update kafka cluster: %v", errors.ClusterResizeNotSupported)
return -1, errors.New(errors.ClusterResizeNotSupportedErrorMsg)
}
// Durability Checks
if *currentCluster.GetSpec().Availability == highAvailability && cku <= 1 {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/kafka/command_topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (c *authenticatedTopicCommand) getNumPartitions(topicName string) (int, err
if err == nil && httpResp != nil {
if httpResp.StatusCode != http.StatusOK {
return 0, errors.NewErrorWithSuggestions(
fmt.Sprintf(errors.KafkaRestUnexpectedStatusMsg, httpResp.Request.URL, httpResp.StatusCode),
fmt.Sprintf(errors.KafkaRestUnexpectedStatusErrorMsg, httpResp.Request.URL, httpResp.StatusCode),
errors.InternalServerErrorSuggestions)
}

Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/kafka/command_topic_consume.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ func (c *hasAPIKeyTopicCommand) consume(cmd *cobra.Command, args []string) error

consumer, err := newConsumer(group, cluster, c.clientID, configFile, config)
if err != nil {
return fmt.Errorf(errors.FailedToCreateConsumerMsg, err)
return fmt.Errorf(errors.FailedToCreateConsumerErrorMsg, err)
}
log.CliLogger.Trace("Create consumer succeeded")

adminClient, err := ckafka.NewAdminClientFromConsumer(consumer)
if err != nil {
return fmt.Errorf(errors.FailedToCreateAdminClientMsg, err)
return fmt.Errorf(errors.FailedToCreateAdminClientErrorMsg, err)
}
defer adminClient.Close()

Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/kafka/command_topic_consume_onprem.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (c *authenticatedTopicCommand) onPremConsume(cmd *cobra.Command, args []str

consumer, err := newOnPremConsumer(cmd, c.clientID, configFile, config)
if err != nil {
return errors.NewErrorWithSuggestions(fmt.Errorf(errors.FailedToCreateConsumerMsg, err).Error(), errors.OnPremConfigGuideSuggestion)
return errors.NewErrorWithSuggestions(fmt.Errorf(errors.FailedToCreateConsumerErrorMsg, err).Error(), errors.OnPremConfigGuideSuggestions)
}
log.CliLogger.Tracef("Create consumer succeeded")

Expand All @@ -103,7 +103,7 @@ func (c *authenticatedTopicCommand) onPremConsume(cmd *cobra.Command, args []str

adminClient, err := ckafka.NewAdminClientFromConsumer(consumer)
if err != nil {
return fmt.Errorf(errors.FailedToCreateAdminClientMsg, err)
return fmt.Errorf(errors.FailedToCreateAdminClientErrorMsg, err)
}
defer adminClient.Close()

Expand Down Expand Up @@ -144,7 +144,7 @@ func (c *authenticatedTopicCommand) onPremConsume(cmd *cobra.Command, args []str
if valueFormat != "string" {
// Only initialize client and context when schema is specified.
if c.State == nil { // require log-in to use oauthbearer token
return errors.NewErrorWithSuggestions(errors.NotLoggedInErrorMsg, errors.AuthTokenSuggestion)
return errors.NewErrorWithSuggestions(errors.NotLoggedInErrorMsg, errors.AuthTokenSuggestions)
}
srClient, ctx, err = sr.GetSrApiClientWithToken(cmd, c.Version, c.AuthToken())
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/kafka/command_topic_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (c *authenticatedTopicCommand) create(cmd *cobra.Command, args []string) er
if err == nil && httpResp != nil {
if httpResp.StatusCode != http.StatusCreated {
return errors.NewErrorWithSuggestions(
fmt.Sprintf(errors.KafkaRestUnexpectedStatusMsg, httpResp.Request.URL, httpResp.StatusCode),
fmt.Sprintf(errors.KafkaRestUnexpectedStatusErrorMsg, httpResp.Request.URL, httpResp.StatusCode),
errors.InternalServerErrorSuggestions)
}
// Kafka REST is available and there was no error
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/kafka/command_topic_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (c *authenticatedTopicCommand) delete(cmd *cobra.Command, args []string) er
if err == nil && httpResp != nil {
if httpResp.StatusCode != http.StatusNoContent {
return errors.NewErrorWithSuggestions(
fmt.Sprintf(errors.KafkaRestUnexpectedStatusMsg, httpResp.Request.URL, httpResp.StatusCode),
fmt.Sprintf(errors.KafkaRestUnexpectedStatusErrorMsg, httpResp.Request.URL, httpResp.StatusCode),
errors.InternalServerErrorSuggestions)
}
// Topic successfully deleted
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/kafka/command_topic_describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (c *authenticatedTopicCommand) describe(cmd *cobra.Command, args []string)
if err == nil && httpResp != nil {
if httpResp.StatusCode != http.StatusOK {
return errors.NewErrorWithSuggestions(
fmt.Sprintf(errors.KafkaRestUnexpectedStatusMsg, httpResp.Request.URL, httpResp.StatusCode),
fmt.Sprintf(errors.KafkaRestUnexpectedStatusErrorMsg, httpResp.Request.URL, httpResp.StatusCode),
errors.InternalServerErrorSuggestions)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/kafka/command_topic_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (c *authenticatedTopicCommand) list(cmd *cobra.Command, _ []string) error {
if err == nil && httpResp != nil {
if httpResp.StatusCode != http.StatusOK {
return errors.NewErrorWithSuggestions(
fmt.Sprintf(errors.KafkaRestUnexpectedStatusMsg, httpResp.Request.URL, httpResp.StatusCode),
fmt.Sprintf(errors.KafkaRestUnexpectedStatusErrorMsg, httpResp.Request.URL, httpResp.StatusCode),
errors.InternalServerErrorSuggestions)
}
// Kafka REST is available and there was no error
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/kafka/command_topic_produce.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ func (c *hasAPIKeyTopicCommand) produce(cmd *cobra.Command, args []string) error

producer, err := newProducer(cluster, c.clientID, configFile, config)
if err != nil {
return fmt.Errorf(errors.FailedToCreateProducerMsg, err)
return fmt.Errorf(errors.FailedToCreateProducerErrorMsg, err)
}
defer producer.Close()
log.CliLogger.Tracef("Create producer succeeded")

adminClient, err := ckafka.NewAdminClientFromProducer(producer)
if err != nil {
return fmt.Errorf(errors.FailedToCreateAdminClientMsg, err)
return fmt.Errorf(errors.FailedToCreateAdminClientErrorMsg, err)
}
defer adminClient.Close()

Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/kafka/command_topic_produce_onprem.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (c *authenticatedTopicCommand) onPremProduce(cmd *cobra.Command, args []str

producer, err := newOnPremProducer(cmd, c.clientID, configFile, config)
if err != nil {
return errors.NewErrorWithSuggestions(fmt.Errorf(errors.FailedToCreateProducerMsg, err).Error(), errors.OnPremConfigGuideSuggestion)
return errors.NewErrorWithSuggestions(fmt.Errorf(errors.FailedToCreateProducerErrorMsg, err).Error(), errors.OnPremConfigGuideSuggestions)
}
defer producer.Close()
log.CliLogger.Tracef("Create producer succeeded")
Expand All @@ -83,7 +83,7 @@ func (c *authenticatedTopicCommand) onPremProduce(cmd *cobra.Command, args []str

adminClient, err := ckafka.NewAdminClientFromProducer(producer)
if err != nil {
return fmt.Errorf(errors.FailedToCreateAdminClientMsg, err)
return fmt.Errorf(errors.FailedToCreateAdminClientErrorMsg, err)
}
defer adminClient.Close()

Expand Down Expand Up @@ -205,7 +205,7 @@ func (c *authenticatedTopicCommand) registerSchema(cmd *cobra.Command, schemaCfg
referencePathMap := map[string]string{}
if schemaCfg.ValueFormat != "string" && len(*schemaCfg.SchemaPath) > 0 {
if c.State == nil { // require log-in to use oauthbearer token
return nil, nil, errors.NewErrorWithSuggestions(errors.NotLoggedInErrorMsg, errors.AuthTokenSuggestion)
return nil, nil, errors.NewErrorWithSuggestions(errors.NotLoggedInErrorMsg, errors.AuthTokenSuggestions)
}
srClient, ctx, err := sr.GetSrApiClientWithToken(cmd, c.Version, c.AuthToken())
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/kafka/command_topic_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (c *authenticatedTopicCommand) update(cmd *cobra.Command, args []string) er
if err == nil && httpResp != nil {
if httpResp.StatusCode != http.StatusNoContent {
return errors.NewErrorWithSuggestions(
fmt.Sprintf(errors.KafkaRestUnexpectedStatusMsg, httpResp.Request.URL, httpResp.StatusCode),
fmt.Sprintf(errors.KafkaRestUnexpectedStatusErrorMsg, httpResp.Request.URL, httpResp.StatusCode),
errors.InternalServerErrorSuggestions)
}

Expand All @@ -121,7 +121,7 @@ func (c *authenticatedTopicCommand) update(cmd *cobra.Command, args []string) er
if err != nil {
return kafkaRestError(kafkaREST.Client.GetConfig().BasePath, err, httpResp)
} else if configsResp.Data == nil {
return errors.NewErrorWithSuggestions(errors.EmptyResponseMsg, errors.InternalServerErrorSuggestions)
return errors.NewErrorWithSuggestions(errors.EmptyResponseErrorMsg, errors.InternalServerErrorSuggestions)
}
readOnlyConfigs := set.New()
configsValues := make(map[string]string)
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/kafka/confluent_kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (c *authenticatedTopicCommand) refreshOAuthBearerToken(cmd *cobra.Command,
if protocol == "SASL_SSL" && mechanism == "OAUTHBEARER" {
oart := ckafka.OAuthBearerTokenRefresh{Config: oauthConfig}
if c.State == nil { // require log-in to use oauthbearer token
return errors.NewErrorWithSuggestions(errors.NotLoggedInErrorMsg, errors.AuthTokenSuggestion)
return errors.NewErrorWithSuggestions(errors.NotLoggedInErrorMsg, errors.AuthTokenSuggestions)
}
oauthBearerToken, retrieveErr := retrieveUnsecuredToken(oart, c.AuthToken())
if retrieveErr != nil {
Expand Down Expand Up @@ -249,7 +249,7 @@ func runConsumer(cmd *cobra.Command, consumer *ckafka.Consumer, groupHandler *Gr
for run {
select {
case <-signals: // Trap SIGINT to trigger a shutdown.
utils.ErrPrintln(cmd, errors.StoppingConsumer)
utils.ErrPrintln(cmd, errors.StoppingConsumerMsg)
consumer.Close()
run = false
default:
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/kafka/confluent_kafka_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func setProtocolConfig(cmd *cobra.Command, configMap *ckafka.ConfigMap) (*ckafka
return nil, err
}
default:
return nil, errors.NewErrorWithSuggestions(fmt.Errorf(errors.InvalidSecurityProtocolErrorMsg, protocol).Error(), errors.OnPremConfigGuideSuggestion)
return nil, errors.NewErrorWithSuggestions(fmt.Errorf(errors.InvalidSecurityProtocolErrorMsg, protocol).Error(), errors.OnPremConfigGuideSuggestions)
}
return configMap, nil
}
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/kafka/kafka_rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ func kafkaRestError(url string, err error, httpResp *http.Response) error {
switch e := err.(type) {
case *neturl.Error:
if strings.Contains(e.Error(), SelfSignedCertError) || strings.Contains(e.Error(), UnauthorizedCertError) {
return errors.NewErrorWithSuggestions(fmt.Sprintf(errors.KafkaRestConnectionMsg, url, e.Err), errors.KafkaRestCertErrorSuggestions)
return errors.NewErrorWithSuggestions(fmt.Sprintf(errors.KafkaRestConnectionErrorMsg, url, e.Err), errors.KafkaRestCertErrorSuggestions)
}
return errors.Errorf(errors.KafkaRestConnectionMsg, url, e.Err)
return errors.Errorf(errors.KafkaRestConnectionErrorMsg, url, e.Err)
case kafkarestv3.GenericOpenAPIError:
openAPIError, parseErr := parseOpenAPIError(err)
if parseErr == nil {
if strings.Contains(openAPIError.Message, "invalid_token") {
return errors.NewErrorWithSuggestions(errors.InvalidMDSToken, errors.InvalidMDSTokenSuggestions)
return errors.NewErrorWithSuggestions(errors.InvalidMDSTokenErrorMsg, errors.InvalidMDSTokenSuggestions)
}
return fmt.Errorf("REST request failed: %v (%v)", openAPIError.Message, openAPIError.Code)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/kafka/kafka_rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (suite *KafkaRestTestSuite) TestKafkaRestError() {

r = kafkaRestError(url, openAPIError, nil)
req.NotNil(r)
req.Contains(r.Error(), "Unknown")
req.Contains(r.Error(), "unknown")

httpResp := http.Response{
Status: "Code: 400",
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/ksql/command_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (c *ksqlCommand) delete(cmd *cobra.Command, args []string, isApp bool) erro
if err != nil {
return err
}
return errors.Errorf(errors.KsqlDBTerminateClusterMsg, args[0], string(body))
return errors.Errorf(errors.KsqlDBTerminateClusterErrorMsg, args[0], string(body))
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/login/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func validateURL(url string, isCCloud bool) (string, string, error) {
}
matched, _ := regexp.MatchString(pattern, url)
if !matched {
return url, "", errors.New(errors.InvalidLoginURLMsg)
return url, "", errors.New(errors.InvalidLoginURLErrorMsg)
}

return url, strings.Join(msg, " and "), nil
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/login/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ func TestValidateUrl(t *testing.T) {
urlIn: "https:///test.com",
urlOut: "",
warningMsg: "default MDS port 8090",
errMsg: errors.InvalidLoginURLMsg,
errMsg: errors.InvalidLoginURLErrorMsg,
},
{
urlIn: "test.com",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (c *schemaCommand) onPremCreate(cmd *cobra.Command, _ []string) error {

func (c *schemaCommand) registerSchemaOnPrem(cmd *cobra.Command, schemaCfg *RegisterSchemaConfigs) ([]byte, map[string]string, error) {
if c.State == nil { // require log-in to use oauthbearer token
return nil, nil, errors.NewErrorWithSuggestions(errors.NotLoggedInErrorMsg, errors.AuthTokenSuggestion)
return nil, nil, errors.NewErrorWithSuggestions(errors.NotLoggedInErrorMsg, errors.AuthTokenSuggestions)
}
srClient, ctx, err := GetSrApiClientWithToken(cmd, c.Version, c.AuthToken())
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/schema-registry/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func getPackageInternalName(inputPackageDisplayName string) (string, error) {
}
}

return "", errors.NewErrorWithSuggestions(fmt.Sprintf(errors.SRInvalidPackageType, inputPackageDisplayName),
return "", errors.NewErrorWithSuggestions(fmt.Sprintf(errors.SRInvalidPackageTypeErrorMsg, inputPackageDisplayName),
fmt.Sprintf(errors.SRInvalidPackageSuggestions, getCommaDelimitedPackagesString()))
}

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/auth/auth_token_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (a *AuthTokenHandlerImpl) checkSSOEmailMatchesLogin(client *ccloud.Client,
return err
}
if getMeReply.User.Email != loginEmail {
return errors.NewErrorWithSuggestions(fmt.Sprintf(errors.SSOCredentialsDoNotMatchLoginCredentials, loginEmail, getMeReply.User.Email), errors.SSOCredentialsDoNotMatchSuggestions)
return errors.NewErrorWithSuggestions(fmt.Sprintf(errors.SSOCredentialsDoNotMatchLoginCredentialsErrorMsg, loginEmail, getMeReply.User.Email), errors.SSOCredentialsDoNotMatchSuggestions)
}
return nil
}
2 changes: 1 addition & 1 deletion internal/pkg/cmd/prerunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ func (r *PreRun) HasAPIKey(command *HasAPIKeyCLICommand) func(*cobra.Command, []
cluster.APIKeys[key] = &v1.APIKeyPair{Key: key, Secret: secret}
} else if cluster.APIKeys[key] == nil {
return errors.NewErrorWithSuggestions(
fmt.Sprintf(errors.NoAPISecretStoredOrPassedMsg, key, clusterId),
fmt.Sprintf(errors.NoAPISecretStoredOrPassedErrorMsg, key, clusterId),
fmt.Sprintf(errors.NoAPISecretStoredOrPassedSuggestions, key, clusterId))
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cmd/prerunner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ func TestPreRun_HasAPIKeyCommand(t *testing.T) {
{
name: "api key passed via flag without stored secret",
key: "miles",
errMsg: fmt.Sprintf(errors.NoAPISecretStoredOrPassedMsg, "miles", v1.MockKafkaClusterId()),
errMsg: fmt.Sprintf(errors.NoAPISecretStoredOrPassedErrorMsg, "miles", v1.MockKafkaClusterId()),
suggestionsMsg: fmt.Sprintf(errors.NoAPISecretStoredOrPassedSuggestions, "miles", v1.MockKafkaClusterId()),
config: usernameClusterWithoutSecret,
},
Expand Down
4 changes: 3 additions & 1 deletion internal/pkg/errors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Suggestions format
- full sentence
- capitalize first letter
- end with a full stop
- separate suggestions using a newline; do not add a newline at the end of the last sentence
- for sentences ending in a url, put a space between the url and the fullstop
- the variable name must end with *Suggestions*

examples:
Expand Down Expand Up @@ -71,7 +73,7 @@ LookUpRoleSuggestions = "To check for valid roles, use `confluent iam
return errors.NewWrapErrorWithSuggestions(err, fmt.Sprintf(errors.LookUpRoleErrorMsg, roleName), errors.LookUpRoleSuggestions)
```

3. If you know that your error will be used in many places, or need to be caught donwstream and process later, you can define typed error by implenting the `CLITypedError` interface
3. If you know that your error will be used in many places, or needs to be caught downstream and processed later, you can define a typed error by implenting the `CLITypedError` interface
```
type CLITypedError interface {
error
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/errors/catcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func catchCoreV1Errors(err error) error {
func catchCCloudTokenErrors(err error) error {
switch err.(type) {
case *ccloud.InvalidLoginError:
return NewErrorWithSuggestions(InvalidLoginErrorMsg, AvoidTimeoutSuggestion)
return NewErrorWithSuggestions(InvalidLoginErrorMsg, AvoidTimeoutSuggestions)
case *ccloud.InvalidTokenError:
return NewErrorWithSuggestions(CorruptedTokenErrorMsg, CorruptedTokenSuggestions)
case *ccloud.ExpiredTokenError:
Expand Down
Loading