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

Remove worker related flags from GetControllerFlags() #4279

Merged
merged 4 commits into from
May 31, 2024

Conversation

twz123
Copy link
Member

@twz123 twz123 commented Apr 11, 2024

Description

Those are also part of GetWorkerFlags(). In fact, the two commands that use GetControllerFlags() ("controller" and "install"), both also add GetWorkerFlags(), defining them effectively twice. Add tests for the --help output to prove that nothing changed. Make logging CLI option statically typed, which will reject logging settings for unknown component names and introduces a deterministic output in the Cobra command's help texts. Remove the unused kube-proxy component from logging.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

  • Manual test
  • Auto test added

Checklist:

  • My code follows the style guidelines of this project
  • My commit messages are signed-off
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@twz123 twz123 marked this pull request as ready for review April 11, 2024 18:33
@twz123 twz123 requested a review from a team as a code owner April 11, 2024 18:33
jnummelin
jnummelin previously approved these changes Apr 19, 2024
cmd/root_test.go Outdated Show resolved Hide resolved
@twz123 twz123 marked this pull request as draft April 29, 2024 10:18
@twz123 twz123 force-pushed the clean-controller-flags branch 4 times, most recently from 58d624d to 6e6aef5 Compare May 6, 2024 08:48
twz123 added 3 commits May 6, 2024 11:26
This makes it obvious if something on the command line interface changes
(modulo changes to hidden flags and such).

Signed-off-by: Tom Wieczorek <[email protected]>
The data-dir is fetched manually from the flag sets nowadays, so
the global variable was not used at all. Also use the standard pflag
defaulting mechanism for printing the defaults.

Signed-off-by: Tom Wieczorek <[email protected]>
Those are also part of GetWorkerFlags(). In fact, the two commands that
use GetControllerFlags() ("controller" and "install"), both also add
GetWorkerFlags(), defining them effectively twice.

Signed-off-by: Tom Wieczorek <[email protected]>
@twz123 twz123 marked this pull request as ready for review May 6, 2024 09:50
kke
kke previously approved these changes May 6, 2024
This will reject logging settings for unknown component names and
introduces a deterministic output in the Cobra command's help texts.
Remove the unused kube-proxy component from logging.

Signed-off-by: Tom Wieczorek <[email protected]>
Copy link
Contributor

@kke kke left a comment

Choose a reason for hiding this comment

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

Change looks good and it is a good idea to have tests to detect changes in the user facing API aka the CLI flags.

But I think doing that outside of go (or having large chunks of xample output embedded in go tests) via some "golden tests" / characterization testing might be something to explore.

In fact, having something like that in place before this PR would make this PR very easy to validate.

@twz123
Copy link
Member Author

twz123 commented May 29, 2024

Hmm, for a start, we can as well just have the output in separate files and use go:embed or os.ReadFile in the tests to load those.

@twz123 twz123 merged commit ea756b2 into k0sproject:main May 31, 2024
74 checks passed
@twz123 twz123 deleted the clean-controller-flags branch May 31, 2024 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants