Skip to content

Commit

Permalink
Add cluster group to instance logs
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Prodan <[email protected]>
  • Loading branch information
stefanprodan committed Nov 19, 2023
1 parent b1deef0 commit 3ea4d91
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
15 changes: 8 additions & 7 deletions cmd/timoni/bundle_apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")))
}
}

Expand Down Expand Up @@ -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")
}
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/timoni/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 3ea4d91

Please sign in to comment.