Skip to content

Add optional field to CopyOperation - #371

Merged
matheuscscp merged 1 commit into
fluxcd:mainfrom
sohel2020:feat/optional-copy-operation
Jul 22, 2026
Merged

Add optional field to CopyOperation#371
matheuscscp merged 1 commit into
fluxcd:mainfrom
sohel2020:feat/optional-copy-operation

Conversation

@sohel2020

@sohel2020 sohel2020 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #368

Adds a per-copy-entry optional flag to CopyOperation so users can control whether a copy operation that matches no files fails or silently skips.

  • Added Optional bool field to CopyOperation in api/v1beta1/artifactgenerator_types.go
  • Builder respects the flag at three error sites: glob no-match, all-files-excluded, and non-glob path-not-found
  • Regenerated CRD manifests via make generate && make manifests
  • Updated spec docs in docs/spec/v1beta1/artifactgenerators.md
  • Added three test cases covering each skip path

Behavior

Scenario optional: false (default) optional: true
Glob matches no files Error Silent skip
All matched files excluded Error Silent skip
Non-glob source path missing Error Silent skip
Missing source alias Error (always) Error (always)

Backward compatible: Optional is bool with zero value false. Existing CRs without this field preserve current error behavior. The CRD change is additive.

Changes

  • api/v1beta1/artifactgenerator_types.go - new Optional field on CopyOperation
  • config/crd/bases/source.extensions.fluxcd.io_artifactgenerators.yaml - regenerated CRD
  • internal/builder/builder.go - check op.Optional before returning no-match errors
  • internal/builder/builder_test.go - three new test cases in TestBuildErrors
  • docs/spec/v1beta1/artifactgenerators.md - documented optional in Copy Operations section

Test plan

  • go test ./internal/builder/ -run TestBuild -count=1 passes (all existing + new tests)
  • go vet ./... clean
  • go fmt ./... clean
  • make test (full suite, requires network for CRD fetch)

Per issue fluxcd#368, copy operations that match no files now support an
`optional` flag. When true, glob no-match, all-excluded, and
non-glob path-not-found errors are silently skipped instead of
failing reconciliation. Default false preserves existing behavior.

Signed-off-by: Tarikur Rahaman <sohel2020@gmail.com>
@sohel2020
sohel2020 force-pushed the feat/optional-copy-operation branch from 86230d8 to 845d4e9 Compare July 14, 2026 14:33
stefanprodan

This comment was marked as resolved.

@stefanprodan
stefanprodan dismissed their stale review July 22, 2026 09:39

wrong pr

@stefanprodan stefanprodan added enhancement New feature or request area/api API related issues and pull requests area/generator Artifact generation related issues and pull requests labels Jul 22, 2026

@stefanprodan stefanprodan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks @sohel2020 🏅

@stefanprodan
stefanprodan requested a review from matheuscscp July 22, 2026 09:49

@matheuscscp matheuscscp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

@matheuscscp
matheuscscp merged commit 71d1574 into fluxcd:main Jul 22, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api API related issues and pull requests area/generator Artifact generation related issues and pull requests enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ArtifactGenerator: fail when a copy source path does not exist

3 participants