Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fancier success icons #50744

Merged
merged 4 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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{
IstioBaseComponentName: "⛵️",
PilotComponentName: "🧠",
CNIComponentName: "🪢",
ZtunnelComponentName: "🔒",
IngressComponentName: "🛬",
EgressComponentName: "🛫",
linsun marked this conversation as resolved.
Show resolved Hide resolved
}

// 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
8 changes: 4 additions & 4 deletions operator/pkg/util/progress/progress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ func TestProgressLog(t *testing.T) {
expect(`- Processing resources for ` + cnbo + `, ` + cnpo + `. Waiting for deployment`)

bar.ReportError("some error")
expect(` ` + cnbo + ` encountered an error: some error`)
expect(` ` + cnbo + ` encountered an error: some error`)

foo.ReportProgress()
expect(`- Processing resources for ` + cnpo + `.`)

foo.ReportFinished()
expect(` ` + cnpo + ` installed`)
expect(`🧠 ` + cnpo + ` installed`)

p.SetState(StatePruning)
expect(`- Pruning removed resources`)

p.SetState(StateComplete)
expect(` Installation complete`)
expect(` Installation complete`)

p.SetState(StateUninstallComplete)
expect(` Uninstall complete`)
expect(` Uninstall complete`)
}
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