fluxcd / flux2

Open and extensible continuous delivery solution for Kubernetes. Powered by GitOps Toolkit.
https://fluxcd.io
Apache License 2.0
6.34k stars 591 forks source link

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

Open errordeveloper opened 11 months ago

errordeveloper commented 11 months ago

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...

stefanprodan commented 11 months ago

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.

ptfpinho23 commented 3 months ago

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

stefanprodan commented 3 months ago

@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