Skip to content

Add --layer-index flag to pull artifact#5886

Open
stratch1989 wants to merge 1 commit into
fluxcd:mainfrom
stratch1989:feat/pull-artifact-layer-index
Open

Add --layer-index flag to pull artifact#5886
stratch1989 wants to merge 1 commit into
fluxcd:mainfrom
stratch1989:feat/pull-artifact-layer-index

Conversation

@stratch1989
Copy link
Copy Markdown

Closes #4243

What

Adds --layer-index <int> to flux pull artifact. When set, the
underlying oci.Client.Pull is called with WithPullLayerIndex(n) so
the chosen layer is extracted instead of the default first layer. Lets
users pull arbitrary layers from OCI artifacts that were not produced
by flux.

Compatibility

Default flow is unchanged — without --layer-index the command behaves
exactly as before (extracts the first layer with layerIndex: 0 in
oci.Client.Pull).

Precedent

This continues the work from PR #4790 (closed without merge after
21 months of inactivity — no review feedback on the thread, likely
stale-bot closure). That PR no longer applies cleanly because of
unrelated refactors in pull_artifact.go, so this is rewritten from
scratch using the same flag name.

Tests

No existing pull_artifact_test.go in the repo; the change is a
straightforward CLI flag wiring with no extractable helper. Followed
the existing pull_artifact precedent of no test file. Happy to add
coverage if maintainers prefer.

Local testing notes

On Apple Silicon the Makefile's setup-envtest use latest --arch=amd64
step fails (bad CPU type in executable). Ran envtest manually with
--arch=arm64 and KUBEBUILDER_ASSETS pointed at the arm64 dir; the
full cmd/flux/... test suite passes. CI on linux/amd64 should be
unaffected.

The flux pull artifact command currently extracts only the first layer
of the OCI manifest, which prevents pulling arbitrary layers from OCI
artifacts not created by flux. The underlying oci.Client.Pull already
accepts a WithPullLayerIndex option but it was not exposed to the CLI.

Add a --layer-index int flag (default -1, meaning unset) wired through
to oci.WithPullLayerIndex when set. The default flow is unchanged.

Signed-off-by: Ruslan Shaydullin <shaydullin.r.d@outlook.com>
Assisted-by: claude-code/claude-opus-4-7
@matheuscscp
Copy link
Copy Markdown
Member

This PR is adding --layer-index <int>, not --layer-selector <string> like discussed in #4243

@stratch1989
Copy link
Copy Markdown
Author

This PR is adding --layer-index <int>, not --layer-selector <string> like discussed in #4243

I picked --layer-index <int> for a couple of reasons: it's the literal mapping to oci.WithPullLayerIndex(int) (zero-based position), and it matches the flag name in the closed PR #4790 from @ptfpinho23. To me "selector" implied filtering by media-type, which would map to a different option (oci.WithPullLayerType).

If you'd prefer the issue wording: rename to --layer-selector <int> keeping position semantics, or switch to a string-typed flag mapping to WithPullLayerType for media-type filtering. Which one were you thinking?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add --layer-selector to flux pull artifact

2 participants