flux2 icon indicating copy to clipboard operation
flux2 copied to clipboard

add `--layer-selector` to `flux pull artifact`

Open errordeveloper opened this issue 1 year ago • 3 comments

It would be really nice if flux pull artifact supported layer selection in the same way OCIRepository does.

More generally, I do wonder if there is a way to improve make CLI feature parity for some cases like this. It would seem useful to be able to run flux pull with any source object definition and extract it to a dir, respecting all object fields. It might be tricky to handle credentials, but surely not unsolvable, perhaps any secret refs would just have to be passed as flags or env vars, if reading from a cluster is not an option. Of course, when it comes to git, most people are familiar with git clone, however, OCI poses a very specific challenge, one has to understand OCI to make good use of crane (as the first example that comes to mind), I don't know if oras might be a bit easier...

errordeveloper avatar Sep 15 '23 12:09 errordeveloper

Currently the Flux CLI can't pull artifacts not created by it. We could remove this restriction by not using the default here https://github.com/fluxcd/flux2/blob/ebace983b91456e176812fbf70a340198afa20c1/cmd/flux/pull_artifact.go#L86

Then we can add --layer-selector and the CLI could download and unpack any layer from any OCI artifact.

stefanprodan avatar Sep 18 '23 13:09 stefanprodan

If at all possible I'd like to take this one, as I've worked with something similar in the past.

ptfpinho23 avatar May 14 '24 07:05 ptfpinho23

@ptfpinho23 layer selection was implemented in our oci package, you would need to map the option to a CLI flag: https://github.com/fluxcd/pkg/blob/235bfbb67d45b96942f03402b0c33dd5a74b2047/oci/client/pull.go#L50

stefanprodan avatar May 14 '24 08:05 stefanprodan