From 3ea4d91515ca2817c68912b35f17bfa44f2cbc9e Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Sun, 19 Nov 2023 18:00:26 +0200 Subject: [PATCH] Add cluster group to instance logs Signed-off-by: Stefan Prodan --- cmd/timoni/bundle_apply.go | 15 ++++++++------- cmd/timoni/log.go | 5 +++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cmd/timoni/bundle_apply.go b/cmd/timoni/bundle_apply.go index 781c2135..55cf64b7 100644 --- a/cmd/timoni/bundle_apply.go +++ b/cmd/timoni/bundle_apply.go @@ -212,12 +212,15 @@ func runBundleApplyCmd(cmd *cobra.Command, _ []string) error { return err } + startMsg := fmt.Sprintf("applying %v instance(s)", len(bundle.Instances)) + if !cluster.IsDefault() { + startMsg = fmt.Sprintf("%s on %s", startMsg, colorizeSubject(cluster.Group)) + } + if bundleApplyArgs.dryrun || bundleApplyArgs.diff { - log.Info(fmt.Sprintf("applying %v instance(s) %s", - len(bundle.Instances), colorizeDryRun("(server dry run)"))) + log.Info(fmt.Sprintf("%s %s", startMsg, colorizeDryRun("(server dry run)"))) } else { - log.Info(fmt.Sprintf("applying %v instance(s)", - len(bundle.Instances))) + log.Info(startMsg) } for _, instance := range bundle.Instances { @@ -422,7 +425,7 @@ func applyBundleInstance(ctx context.Context, cuectx *cue.Context, instance *eng if err != nil { return err } - log.Info("resources are ready") + log.Info(fmt.Sprintf("%s resources %s", set.Name, colorizeReady("ready"))) } } @@ -455,8 +458,6 @@ func applyBundleInstance(ctx context.Context, cuectx *cue.Context, instance *eng if err != nil { return fmt.Errorf("wating for termination failed: %w", err) } - - log.Info("all resources are ready") } } diff --git a/cmd/timoni/log.go b/cmd/timoni/log.go index 20ab2ad2..cd96d4dc 100644 --- a/cmd/timoni/log.go +++ b/cmd/timoni/log.go @@ -68,6 +68,7 @@ func NewConsoleLogger() logr.Logger { var ( colorDryRun = color.New(color.FgHiBlack, color.Italic) colorError = color.New(color.FgHiRed) + colorReady = color.New(color.FgHiGreen) colorCallerPrefix = color.New(color.FgHiBlack) colorBundle = color.New(color.FgHiMagenta) colorInstance = color.New(color.FgHiMagenta) @@ -134,6 +135,10 @@ func colorizeSubject(subject string) string { return color.CyanString(subject) } +func colorizeReady(subject string) string { + return colorReady.Sprint(subject) +} + func colorizeInfo(subject string) string { return color.GreenString(subject) }