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 colors to describe command #3275

Merged
merged 7 commits into from
Feb 9, 2021

Conversation

mike1808
Copy link
Contributor

  • Add colors to describe backups/restore/schedules commands
  • Make name in the output bold
  • Disable colors via --colorized flag or if velero isn't in TTY

Fixes #1082

If you have any other coloring suggestion please let us know.

cc @KauzClay

Copy link
Contributor

@jenting jenting left a comment

Choose a reason for hiding this comment

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

Please run make update to fix CI failure. Thank you.

@jenting jenting added the Area/CLI related to the command-line interface label Jan 21, 2021
nrb
nrb previously requested changes Jan 22, 2021
Copy link
Contributor

@nrb nrb left a comment

Choose a reason for hiding this comment

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

This is really cool, thank you!

I have an additional request - can you add enabling/disabling this functionality into the Velero client config file, so folks can disable it for all runs? The file lives in $HOME/.config/velero, and we have helper code for it that will need to read the key. We should have existing code for the feature flags that allows for using the config file and command line flags.

@KauzClay
Copy link
Member

KauzClay commented Jan 22, 2021

Hey @nrb ,

When you say you want it to be enabled/disabled via the config file, do you imagine it being part of "features", like this?
{"features": "colors"}

Or were you imagining a separate config field entirely, like this?
{"features":"foo","colors":"off"}

EDIT:
We went with the second option, since "features" seem to be disabled by default, and we added colorized to be enabled by default.

Please let us know if you would prefer it a different way!

@mike1808 mike1808 removed their assignment Jan 22, 2021
@nrb
Copy link
Contributor

nrb commented Jan 22, 2021

Or were you imagining a separate config field entirely, like this?

Yep! features are for feature flags that get passed from the client to the server to the plugins. Since this is purely clientside, I think it makes sense to be a dedicated field.

carlisia
carlisia previously approved these changes Jan 22, 2021
Copy link
Contributor

@carlisia carlisia left a comment

Choose a reason for hiding this comment

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

This LGTM! 🎉

@carlisia
Copy link
Contributor

Hey @mike1808, your last commit was unsigned and so it's failing a check.

Copy link
Contributor

@jenting jenting left a comment

Choose a reason for hiding this comment

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

I disabled the colorized in my $HOME/.config/velero/config.json as {"colorized":"false"}.
However, the color still existed for the command output.

@mike1808
Copy link
Contributor Author

@jenting please use boolean values instead of strings.

@jenting
Copy link
Contributor

jenting commented Jan 27, 2021

@jenting please use boolean values instead of strings.

I think the problem comes when I running velero client config set colorized=false, the $HOME/.config/velero/config.json would be {"colorized":"false"}.

If I manually edit $HOME/.config/velero/config.json to {"colorized":false}, the color is out.
But if I running velero client config get, if shows colorized: %!s(bool=false).

@KauzClay
Copy link
Member

@jenting I see, is there a preference then for all config values to be strings then? We could change the value to a string and it could be on/off instead of true/false?

Or we could do some converting in the VeleroConfig struct to allow for the bool. Do you have a preference?

@jenting
Copy link
Contributor

jenting commented Jan 28, 2021

@jenting I see, is there a preference then for all config values to be strings then? We could change the value to a string and it could be on/off instead of true/false?

cc @nrb @carlisia @zubron any suggestion on this?

Personally, I'd prefer not to break the change (keep using the strings type).
Either "on"/"off" or "true"/"false" is fine to me.

Or we could do some converting in the VeleroConfig struct to allow for the bool. Do you have a preference?

@jenting
Copy link
Contributor

jenting commented Jan 30, 2021

Thank you. Two comments left:

  1. It'd be better to add doc for this nice feature
  2. Please fix the conflicting files

* Add colors to describe backups/restore/schedules commands
* Make name in the output bold
* Disable colors via `--colorized` flag or if velero isn't in TTY

Co-authored-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Signed-off-by: Mikael Manukyan <mmanukyan@vmware.com>
@KauzClay KauzClay force-pushed the colorized-describe branch 2 times, most recently from a13593c to c276d18 Compare February 1, 2021 19:19
@KauzClay
Copy link
Member

KauzClay commented Feb 1, 2021

Hi @jenting , I think we resolved the conflicting files. As for the doc, we weren't sure where to put this information. We opted for site/content/docs/main/customize-installation.md, since we saw other references to client config there. If that isn't okay, could you please explain where you were envisioning this documentation to live?

@jenting
Copy link
Contributor

jenting commented Feb 2, 2021

We opted for site/content/docs/main/customize-installation.md, since we saw other references to client config there.

I'm okay to put it here.

I saw the last two commits had signed off, but the CI failed at DCO check, strange 🤔

velero client config set colorized=false
```

Note, that if you specify `--colorized=true` as a CLI option it will override
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Note, that if you specify `--colorized=true` as a CLI option it will override
Note that if you specify `--colorized=true` as a CLI option it will override

@carlisia
Copy link
Contributor

carlisia commented Feb 2, 2021

@jenting thanks for testing this.

@KauzClay this looks great and ready to merge as far as I'm concerned except for:

  • the biggest/tinniest nit pick ever (see above)
  • we need to make the DCO check pass

Thank you.

@nrb
Copy link
Contributor

nrb commented Feb 3, 2021

@KauzClay Once you make the two changes asked for, please sign the commits as shown at https://github.com/vmware-tanzu/velero/pull/3275/checks?check_run_id=1809391225

@KauzClay
Copy link
Member

KauzClay commented Feb 8, 2021

Ah, sorry about messing up the sign off thing. Hopefully I got it this time?

KauzClay and others added 6 commits February 8, 2021 23:16
* and run make update

Co-authored-by: Mikael Manukyan <mmanukyan@vmware.com>
Signed-off-by: Mikael Manukyan <mmanukyan@vmware.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Co-authored-by: Mikael Manukyan <mmanukyan@vmware.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Co-authored-by: Mikael Manukyan <mmanukyan@vmware.com>
* the command `velero client config set colorized=false` writes a string
value of "false" into the config. This change allows that string to be
accepted and converted into a boolean when used in program.

Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Co-authored-by: Mikael Manukyan <mmanukyan@vmware.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Co-authored-by: JenTing Hsiao <jenting.hsiao@suse.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>
* as per @carlisia 's suggestion

Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Copy link
Contributor

@jenting jenting left a comment

Choose a reason for hiding this comment

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

LGTM, thank you.

@carlisia carlisia merged commit 36fc427 into vmware-tanzu:main Feb 9, 2021
dharmab pushed a commit to dharmab/velero that referenced this pull request May 25, 2021
* Add colors to describe command

* Add colors to describe backups/restore/schedules commands
* Make name in the output bold
* Disable colors via `--colorized` flag or if velero isn't in TTY

Co-authored-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Signed-off-by: Mikael Manukyan <mmanukyan@vmware.com>

* Add changelog
* and run make update

Co-authored-by: Mikael Manukyan <mmanukyan@vmware.com>
Signed-off-by: Mikael Manukyan <mmanukyan@vmware.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>

* Add colorized to the client config file

Co-authored-by: Mikael Manukyan <mmanukyan@vmware.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Co-authored-by: Mikael Manukyan <mmanukyan@vmware.com>

* allow client config to use string values

* the command `velero client config set colorized=false` writes a string
value of "false" into the config. This change allows that string to be
accepted and converted into a boolean when used in program.

Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>

* Add docs about colored CLI output

Co-authored-by: Mikael Manukyan <mmanukyan@vmware.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>

* Update site/content/docs/main/customize-installation.md

Co-authored-by: JenTing Hsiao <jenting.hsiao@suse.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>

* docs: remove comma

* as per @carlisia 's suggestion

Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>

Co-authored-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Co-authored-by: Clay Kauzlaric <clay.kauzlaric@gmail.com>
Co-authored-by: JenTing Hsiao <jenting.hsiao@suse.com>
ywk253100 pushed a commit to ywk253100/velero that referenced this pull request Jun 29, 2021
* Add colors to describe command

* Add colors to describe backups/restore/schedules commands
* Make name in the output bold
* Disable colors via `--colorized` flag or if velero isn't in TTY

Co-authored-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Signed-off-by: Mikael Manukyan <mmanukyan@vmware.com>

* Add changelog
* and run make update

Co-authored-by: Mikael Manukyan <mmanukyan@vmware.com>
Signed-off-by: Mikael Manukyan <mmanukyan@vmware.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>

* Add colorized to the client config file

Co-authored-by: Mikael Manukyan <mmanukyan@vmware.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Co-authored-by: Mikael Manukyan <mmanukyan@vmware.com>

* allow client config to use string values

* the command `velero client config set colorized=false` writes a string
value of "false" into the config. This change allows that string to be
accepted and converted into a boolean when used in program.

Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>

* Add docs about colored CLI output

Co-authored-by: Mikael Manukyan <mmanukyan@vmware.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>

* Update site/content/docs/main/customize-installation.md

Co-authored-by: JenTing Hsiao <jenting.hsiao@suse.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>

* docs: remove comma

* as per @carlisia 's suggestion

Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>

Co-authored-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Co-authored-by: Clay Kauzlaric <clay.kauzlaric@gmail.com>
Co-authored-by: JenTing Hsiao <jenting.hsiao@suse.com>
gyaozhou pushed a commit to gyaozhou/velero-read that referenced this pull request May 14, 2022
* Add colors to describe command

* Add colors to describe backups/restore/schedules commands
* Make name in the output bold
* Disable colors via `--colorized` flag or if velero isn't in TTY

Co-authored-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Signed-off-by: Mikael Manukyan <mmanukyan@vmware.com>

* Add changelog
* and run make update

Co-authored-by: Mikael Manukyan <mmanukyan@vmware.com>
Signed-off-by: Mikael Manukyan <mmanukyan@vmware.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>

* Add colorized to the client config file

Co-authored-by: Mikael Manukyan <mmanukyan@vmware.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Co-authored-by: Mikael Manukyan <mmanukyan@vmware.com>

* allow client config to use string values

* the command `velero client config set colorized=false` writes a string
value of "false" into the config. This change allows that string to be
accepted and converted into a boolean when used in program.

Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>

* Add docs about colored CLI output

Co-authored-by: Mikael Manukyan <mmanukyan@vmware.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>

* Update site/content/docs/main/customize-installation.md

Co-authored-by: JenTing Hsiao <jenting.hsiao@suse.com>
Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>

* docs: remove comma

* as per @carlisia 's suggestion

Signed-off-by: Clay Kauzlaric <ckauzlaric@vmware.com>

Co-authored-by: Clay Kauzlaric <ckauzlaric@vmware.com>
Co-authored-by: Clay Kauzlaric <clay.kauzlaric@gmail.com>
Co-authored-by: JenTing Hsiao <jenting.hsiao@suse.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/CLI related to the command-line interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Colored output
5 participants