flux2
flux2 copied to clipboard
Refactor CLI commands into dedicated packages
The current CLI code structure is error prone and makes it hard to spot bugs, we should create a dedicated package per command.
Prerequisites:
- [x] Refactor cmd global variables into structs (implemented in #755)
- [x] Refactor
flux get
commands to use the generic adaptor
First step would be to encapsulate each command flags into a struct, e.g. https://github.com/fluxcd/flux2/blob/main/cmd/flux/create_image_policy.go#L40 then rewrite the get
commands to use the https://github.com/fluxcd/flux2/blob/main/cmd/flux/object.go e.g. https://github.com/fluxcd/flux2/blob/main/cmd/flux/get_image_policy.go#L35
Picking this up
I see a lot of things were merged related to this, but it seems like the CLI functions are still all in one package. I read this issue as stating that they should be broken out into multiple packages, so that they are easier to test. (Is this still ongoing?)
We've found a discussion which adds some further context around this issue: https://github.com/fluxcd/flux2/discussions/707