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

fix: properly remove emojis in pretty format with no color #765

Merged
merged 2 commits into from
Jul 28, 2022

Conversation

weisdd
Copy link
Contributor

@weisdd weisdd commented May 20, 2022

This PR fixes #764

Checklist

  • I have signed the CLA
  • I have updated/added any relevant documentation

Description

What's the goal of this PR?

The goal is to fix emojis removal from pretty outputs in colorless mode. Without the fix, you'd get broken binary symbols, e.g.:

Deployment app
    deploymentMissingReplicas            �� Success
        Reliability - Multiple replicas are scheduled

What changes did you make?

I haven't seen any double-worded status fields, so instead of slicing, just extracted a word after a whitespace.

status = strings.Fields(status)[1]

If there's a need to have such double-worded names, we can replace the code with:

status = strings.Join(strings.Fields(status)[1:], " ")

or any other implementation. In Go 1.18, to which the project hasn't migrated yet, there's strings.Cut(), which I am a fan of. :)

What alternative solution should we consider, if any?

Not really an alternative, but currently I have to play with sed to remove those symbols.

Signed-off-by: Igor Beliakov <demtis.register@gmail.com>
@weisdd weisdd requested review from rbren and makoscafee as code owners May 20, 2022 08:39
@CLAassistant
Copy link

CLAassistant commented May 20, 2022

CLA assistant check
All committers have signed the CLA.

@@ -211,7 +212,7 @@ func (res ResultSet) GetPrettyOutput() string {
}
}
if color.NoColor {
status = status[2:] // remove emoji
status = strings.Fields(status)[1] // remove emoji
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this would be safer as

strings.Join(strings.Fields(status)[1:], " ")

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably not a big deal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rbren Please, feel free to adjust it to whatever serves the project best :)

@rbren rbren enabled auto-merge (squash) July 28, 2022 19:32
@rbren rbren merged commit 652b65b into FairwindsOps:master Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emojis are not fully stripped in pretty format with no colors
3 participants