Skip to content

Add optional field to CopyOperation#371

Open
sohel2020 wants to merge 1 commit into
fluxcd:mainfrom
sohel2020:feat/optional-copy-operation
Open

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

Conversation

@sohel2020

@sohel2020 sohel2020 commented Jul 14, 2026

Copy link
Copy Markdown

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

ArtifactGenerator: fail when a copy source path does not exist

1 participant