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

Ensure cobra command isolation #334

Open
mflendrich opened this issue Apr 21, 2021 · 1 comment
Open

Ensure cobra command isolation #334

mflendrich opened this issue Apr 21, 2021 · 1 comment

Comments

@mflendrich
Copy link
Contributor

There's a new class of quality issues in deck (see #331 and #288): cobra Commands wrongly overwriting or reading values meant for other commands.

I propose that we improve maintainability/modularity of decK by refactoring cobra commands so that:

  • each lives in a separate package
  • each defines a struct Config and has flags bound to a single instance of that struct
  • implementation of a command is decoupled from cobra, and takes the aforementioned struct Config as its input

I did something similar on one of my past projects: https://github.com/weaveworks/wksctl/blob/0184323ebc93df96544a1e3b55c84fbd3d292641/cmd/wksctl/main.go#L47

@mflendrich
Copy link
Contributor Author

mflendrich commented Apr 21, 2021

Notes after a discussion with @hbagdi:

  • We need to ensure no regression for users configuring decK with either a config file or env variables (as supported by viper)
  • Currently viper binds flags to env vars on the global level - this may need some rearrangement.
  • Env variables (that are not settings) are also used in feat(file) implement env var substitution for state files #286 and whatever we implement, that needs to work with env var substitution implemented in that PR.

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

No branches or pull requests

1 participant