flux2 icon indicating copy to clipboard operation
flux2 copied to clipboard

Refactor CLI commands into dedicated packages

Open stefanprodan opened this issue 3 years ago • 4 comments

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

stefanprodan avatar Oct 02 '20 13:10 stefanprodan

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

stefanprodan avatar Jan 21 '21 08:01 stefanprodan

Picking this up

somtochiama avatar Jan 21 '21 09:01 somtochiama

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?)

kingdonb avatar Oct 06 '21 12:10 kingdonb

We've found a discussion which adds some further context around this issue: https://github.com/fluxcd/flux2/discussions/707

kingdonb avatar Jan 12 '22 13:01 kingdonb