django-qsessions icon indicating copy to clipboard operation
django-qsessions copied to clipboard

Ensure cobra command isolation

Open mflendrich opened this issue 3 years ago • 1 comments

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 avatar Apr 21 '21 13:04 mflendrich