Skip to content

Commit

Permalink
add fancier success icons
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Rudie <[email protected]>
  • Loading branch information
ilrudie committed Apr 29, 2024
1 parent f8fdd54 commit 2c17356
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
9 changes: 9 additions & 0 deletions operator/pkg/name/name.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ const (
IstioOperatorCustomResourceName ComponentName = "IstioOperatorCustomResource"
)

var IstioComponentSuccessIcons map[ComponentName]string = map[ComponentName]string{
IstioBaseComponentName: "⛵️",
PilotComponentName: "🧠",
CNIComponentName: "🚦",
ZtunnelComponentName: "🔒",
IngressComponentName: "🚪",
EgressComponentName: "✋",
}

// ComponentNamesConfig is used for unmarshaling legacy and addon naming data.
type ComponentNamesConfig struct {
DeprecatedComponentNames []string
Expand Down
15 changes: 10 additions & 5 deletions operator/pkg/util/progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ func createBar() *pb.ProgressBar {
// on a new line, and create a new bar. For example, this becomes "x succeeded", "waiting for y, z".
func (p *Log) reportProgress(component string) func() {
return func() {
cliName := name.UserFacingComponentName(name.ComponentName(component))
cmpName := name.ComponentName(component)
cliName := name.UserFacingComponentName(cmpName)
p.mu.Lock()
defer p.mu.Unlock()
cmp := p.components[component]
Expand All @@ -120,11 +121,15 @@ func (p *Log) reportProgress(component string) func() {
finished := cmp.finished
cmpErr := cmp.err
cmp.mu.Unlock()
successIcon := "✅"
if icon, found := name.IstioComponentSuccessIcons[cmpName]; found {
successIcon = icon
}
if finished || cmpErr != "" {
if finished {
p.SetMessage(fmt.Sprintf(`{{ green "✔" }} %s installed`, cliName), true)
p.SetMessage(fmt.Sprintf(`%s %s installed`, successIcon, cliName), true)
} else {
p.SetMessage(fmt.Sprintf(`{{ red "✘" }} %s encountered an error: %s`, cliName, cmpErr), true)
p.SetMessage(fmt.Sprintf(`"❌" %s encountered an error: %s`, cliName, cmpErr), true)
}
// Close the bar out, outputting a new line
delete(p.components, component)
Expand All @@ -146,10 +151,10 @@ func (p *Log) SetState(state InstallState) {
p.bar.SetTemplateString(inProgress + `Pruning removed resources`)
p.bar.Write()
case StateComplete:
p.bar.SetTemplateString(`{{ green "" }} Installation complete`)
p.bar.SetTemplateString(`{{ green "" }} Installation complete`)
p.bar.Write()
case StateUninstallComplete:
p.bar.SetTemplateString(`{{ green "" }} Uninstall complete`)
p.bar.SetTemplateString(`{{ green "" }} Uninstall complete`)
p.bar.Write()
}
}
Expand Down
4 changes: 2 additions & 2 deletions operator/pkg/verifier/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ func NewStatusVerifier(kubeClient kube.CLIClient, client client.Client, istioNam
) (*StatusVerifier, error) {
verifier := StatusVerifier{
logger: clog.NewDefaultLogger(),
successMarker: "",
failureMarker: "",
successMarker: "",
failureMarker: "",
istioNamespace: istioNamespace,
manifestsPath: manifestsPath,
filenames: filenames,
Expand Down

0 comments on commit 2c17356

Please sign in to comment.