Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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 cmd/rhoas/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,5 @@ func initConfig(f *factory.Factory) error {
}

func wrapErrorf(err error, localizer localize.Localizer) error {
return fmt.Errorf("%v %w. %v", icon.Error(), err, localizer.MustLocalize("common.log.error.verboseModeHint"))
return fmt.Errorf("%v %w. %v", icon.ErrorPrefix(), err, localizer.MustLocalize("common.log.error.verboseModeHint"))
}
2 changes: 1 addition & 1 deletion pkg/auth/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (a *AuthorizationCodeGrant) Execute(ctx context.Context, ssoCfg *SSOConfig,
if err := a.loginMAS(ctx, masSSOCfg); err != nil {
return err
}
a.Logger.Info(icon.Success(), a.Localizer.MustLocalize("login.log.info.loggedIn"))
a.Logger.Info(icon.SuccessPrefix(), a.Localizer.MustLocalize("login.log.info.loggedIn"))
a.Logger.Debug(a.Localizer.MustLocalize("login.log.info.loggedInMAS", localize.NewEntry("Host", masSSOHost)))

return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/kcManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func watchForKafkaStatus(c *KubernetesCluster, crName string, namespace string)
return fmt.Errorf(c.localizer.MustLocalize("cluster.kubernetes.watchForKafkaStatus.error.status"), typedCondition["message"])
}
if typedCondition["status"].(string) == "True" {
c.logger.Info(icon.Success(), c.localizer.MustLocalize("cluster.kubernetes.watchForKafkaStatus.log.info.success", localize.NewEntry("Name", crName), localize.NewEntry("Namespace", namespace)))
c.logger.Info(icon.SuccessPrefix(), c.localizer.MustLocalize("cluster.kubernetes.watchForKafkaStatus.log.info.success", localize.NewEntry("Name", crName), localize.NewEntry("Namespace", namespace)))

w.Stop()
return nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/cluster/kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func (c *KubernetesCluster) createTokenSecretIfNeeded(ctx context.Context, names
return fmt.Errorf("%v: %w", c.localizer.MustLocalize("cluster.kubernetes.createTokenSecret.log.info.createFailed", tokenSecretNameTmplEntry), err)
}

c.logger.Info(icon.Success(), c.localizer.MustLocalize("cluster.kubernetes.createTokenSecret.log.info.createSuccess", tokenSecretNameTmplEntry))
c.logger.Info(icon.SuccessPrefix(), c.localizer.MustLocalize("cluster.kubernetes.createTokenSecret.log.info.createSuccess", tokenSecretNameTmplEntry))

return nil
}
Expand Down Expand Up @@ -302,7 +302,7 @@ func (c *KubernetesCluster) createServiceAccountSecretIfNeeded(ctx context.Conte
return fmt.Errorf("%v: %w", c.localizer.MustLocalize("cluster.kubernetes.serviceaccountsecret.error.createError"), err)
}

c.logger.Info(icon.Success(), c.localizer.MustLocalize("cluster.kubernetes.createSASecret.log.info.createSuccess", localize.NewEntry("Name", createdSecret.Name)))
c.logger.Info(icon.SuccessPrefix(), c.localizer.MustLocalize("cluster.kubernetes.createSASecret.log.info.createSuccess", localize.NewEntry("Name", createdSecret.Name)))

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/serviceBinding.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func ExecuteServiceBinding(logger logging.Logger, localizer localize.Localizer,
return err
}

logger.Info(icon.Success(), fmt.Sprintf(localizer.MustLocalize("cluster.serviceBinding.bindingSuccess"), options.ServiceName, options.AppName))
logger.Info(icon.SuccessPrefix(), fmt.Sprintf(localizer.MustLocalize("cluster.serviceBinding.bindingSuccess"), options.ServiceName, options.AppName))
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/kafka/consumergroup/resetoffset/reset_offset.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func runCmd(opts *Options) error {

defer httpRes.Body.Close()

opts.Logger.Info(icon.Success(), opts.localizer.MustLocalize(
opts.Logger.Info(icon.SuccessPrefix(), opts.localizer.MustLocalize(
"kafka.consumerGroup.resetOffset.log.info.successful",
localize.NewEntry("ConsumerGroupID", opts.id),
localize.NewEntry("InstanceName", kafkaInstance.GetName())),
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/kafka/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func runCreate(opts *Options) error {
}
s.Stop()
opts.Logger.Info("\n")
opts.Logger.Info(icon.Success(), opts.localizer.MustLocalize("kafka.create.info.successSync", nameTemplateEntry))
opts.Logger.Info(icon.SuccessPrefix(), opts.localizer.MustLocalize("kafka.create.info.successSync", nameTemplateEntry))
}

switch opts.outputFormat {
Expand All @@ -256,7 +256,7 @@ func runCreate(opts *Options) error {

if !opts.wait {
opts.Logger.Info()
opts.Logger.Info(icon.Success(), opts.localizer.MustLocalize("kafka.create.info.successAsync", nameTemplateEntry))
opts.Logger.Info(opts.localizer.MustLocalize("kafka.create.info.successAsync", nameTemplateEntry))
}

return nil
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/kafka/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"github.com/redhat-developer/app-services-cli/pkg/icon"

"github.com/redhat-developer/app-services-cli/pkg/connection"
kafkacmdutil "github.com/redhat-developer/app-services-cli/pkg/kafka/cmdutil"
Expand Down Expand Up @@ -147,7 +146,7 @@ func runDelete(opts *options) error {
return err
}

opts.Logger.Info(icon.Success(), opts.localizer.MustLocalize("kafka.delete.log.info.deleteSuccess", localize.NewEntry("Name", kafkaName)))
opts.Logger.Info(opts.localizer.MustLocalize("kafka.delete.log.info.deleting", localize.NewEntry("Name", kafkaName)))

currentKafka := cfg.Services.Kafka
// this is not the current cluster, our work here is done
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/kafka/use/use.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func runUse(opts *Options) error {
return fmt.Errorf("%v: %w", saveErrMsg, err)
}

opts.Logger.Info(icon.Success(), opts.localizer.MustLocalize("kafka.use.log.info.useSuccess", nameTmplEntry))
opts.Logger.Info(icon.SuccessPrefix(), opts.localizer.MustLocalize("kafka.use.log.info.useSuccess", nameTmplEntry))

return nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ func runLogin(opts *Options) (err error) {
opts.Logger.Info("")

if !ok {
opts.Logger.Info(icon.Success(), opts.localizer.MustLocalize("login.log.info.loginSuccessNoUsername"))
opts.Logger.Info(icon.SuccessPrefix(), opts.localizer.MustLocalize("login.log.info.loginSuccessNoUsername"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just idea: opts.Logger.Success

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that might make things nicer actually, though I do like keeping the Logger lean and focused on log-levels only.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our logger is not logger per se. It is an stderr printer. Having more high-level methods will be good idea for future issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but the stderr printer is an implementation of a higher-level Logger interface, which could be implemented in different contexts. Though I do not see it being used in ways other than to stderr

} else {
opts.Logger.Info(icon.Success(), opts.localizer.MustLocalize("login.log.info.loginSuccess", localize.NewEntry("Username", username)))
opts.Logger.Info(icon.SuccessPrefix(), opts.localizer.MustLocalize("login.log.info.loginSuccess", localize.NewEntry("Username", username)))
}

// debug mode checks this for a version update also.
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/logout/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func runLogout(opts *Options) error {
return fmt.Errorf("%v: %w", opts.localizer.MustLocalize("logout.error.unableToLogout"), err)
}

opts.Logger.Info(icon.Success(), opts.localizer.MustLocalize("logout.log.info.logoutSuccess"))
opts.Logger.Info(icon.SuccessPrefix(), opts.localizer.MustLocalize("logout.log.info.logoutSuccess"))

return nil
}
2 changes: 1 addition & 1 deletion pkg/cmd/registry/artifact/crud/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ func runGet(opts *Options) error {
fmt.Fprintf(os.Stdout, "%v\n", string(fileContent))
}

opts.Logger.Info(icon.Success(), opts.localizer.MustLocalize("artifact.common.message.fetched.successfully"))
opts.Logger.Info(icon.SuccessPrefix(), opts.localizer.MustLocalize("artifact.common.message.fetched.successfully"))
return nil
}
2 changes: 1 addition & 1 deletion pkg/cmd/registry/artifact/download/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,6 @@ func runGet(opts *Options) error {
fmt.Fprintf(os.Stdout, "%v\n", string(fileContent))
}

opts.Logger.Info(icon.Success(), opts.localizer.MustLocalize("artifact.common.message.fetched.successfully"))
opts.Logger.Info(icon.SuccessPrefix(), opts.localizer.MustLocalize("artifact.common.message.fetched.successfully"))
return nil
}
2 changes: 1 addition & 1 deletion pkg/cmd/registry/artifact/metadata/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func runGet(opts *GetOptions) error {
return registryinstanceerror.TransformError(err)
}

opts.Logger.Info(icon.Success(), opts.localizer.MustLocalize("artifact.common.message.artifact.metadata.fetched"))
opts.Logger.Info(icon.SuccessPrefix(), opts.localizer.MustLocalize("artifact.common.message.artifact.metadata.fetched"))

dump.PrintDataInFormat(opts.outputFormat, response, opts.IO.Out)

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/registry/artifact/metadata/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func runSet(opts *SetOptions) error {
return registryinstanceerror.TransformError(err)
}

opts.Logger.Info(icon.Success(), opts.localizer.MustLocalize("artifact.common.message.artifact.metadata.updated"))
opts.Logger.Info(icon.SuccessPrefix(), opts.localizer.MustLocalize("artifact.common.message.artifact.metadata.updated"))
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/registry/artifact/versions/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func runGet(opts *Options) error {
return registryinstanceerror.TransformError(err)
}

opts.Logger.Info(icon.Success(), opts.localizer.MustLocalize("artifact.common.message.artifact.versions.fetched"))
opts.Logger.Info(icon.SuccessPrefix(), opts.localizer.MustLocalize("artifact.common.message.artifact.versions.fetched"))

dump.PrintDataInFormat(opts.outputFormat, response, opts.IO.Out)

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/registry/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func runCreate(opts *Options) error {
return err
}

opts.Logger.Info(icon.Success(), opts.localizer.MustLocalize("registry.cmd.create.info.successMessage"))
opts.Logger.Info(icon.SuccessPrefix(), opts.localizer.MustLocalize("registry.cmd.create.info.successMessage"))

dump.PrintDataInFormat(opts.outputFormat, response, opts.IO.Out)

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/registry/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func runDelete(opts *options) error {
return err
}

opts.Logger.Info(icon.Success(), opts.localizer.MustLocalize("registry.delete.log.info.deleteSuccess", localize.NewEntry("Name", registryName)))
opts.Logger.Info(icon.SuccessPrefix(), opts.localizer.MustLocalize("registry.delete.log.info.deleteSuccess", localize.NewEntry("Name", registryName)))

currentContextRegistry := cfg.Services.ServiceRegistry
// this is not the current cluster, our work here is done
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/registry/use/use.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func runUse(opts *Options) error {
return fmt.Errorf("%v: %w", saveErrMsg, err)
}

opts.Logger.Info(icon.Success(), opts.localizer.MustLocalize("registry.use.log.info.useSuccess", nameTmplEntry))
opts.Logger.Info(icon.SuccessPrefix(), opts.localizer.MustLocalize("registry.use.log.info.useSuccess", nameTmplEntry))

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/serviceaccount/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func runCreate(opts *Options) error {
return err
}

opts.Logger.Info(icon.Success(), opts.localizer.MustLocalize("serviceAccount.create.log.info.createdSuccessfully", localize.NewEntry("ID", serviceacct.GetId()), localize.NewEntry("Name", serviceacct.GetName())))
opts.Logger.Info(icon.SuccessPrefix(), opts.localizer.MustLocalize("serviceAccount.create.log.info.createdSuccessfully", localize.NewEntry("ID", serviceacct.GetId()), localize.NewEntry("Name", serviceacct.GetName())))

creds := &credentials.Credentials{
ClientID: serviceacct.GetClientId(),
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/serviceaccount/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func deleteServiceAccount(opts *Options) error {
}
}

opts.Logger.Info(icon.Success(), opts.localizer.MustLocalize("serviceAccount.delete.log.info.deleteSuccess"))
opts.Logger.Info(icon.SuccessPrefix(), opts.localizer.MustLocalize("serviceAccount.delete.log.info.deleteSuccess"))

return nil
}
8 changes: 4 additions & 4 deletions pkg/icon/icon.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ func Emoji(emoji string, fallback string) string {
return fallback
}

// Success returns check mark emoji
func Success() string {
// SuccessPrefix returns check mark emoji prefix
func SuccessPrefix() string {
return Emoji("\u2714\ufe0f", "")
}

// Error returns cross mark emoji
func Error() string {
// ErrorPrefix returns cross mark emoji prefix or default "Error:"
func ErrorPrefix() string {
return Emoji("\u274c", "Error:")
}
2 changes: 1 addition & 1 deletion pkg/localize/locales/en/cmd/kafka.en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ one = 'The name you entered does not match the name of the Kafka instance that y
description = 'Debug message when deleting Kafka'
one = 'Deleting Kafka instance'

[kafka.delete.log.info.deleteSuccess]
[kafka.delete.log.info.deleting]
description = 'Info message when instance was deleted'
one = 'Kafka instance "{{.Name}}" is being deleted'

Expand Down