Add PathPattern (directory discovery) to ArtifactGenerator#341
Merged
Conversation
Member
|
@vocarista Please edit the PR description with YAML examples explaining the new feature's behavior. |
matheuscscp
reviewed
Jun 16, 2026
78e1fa9 to
deddf74
Compare
Signed-off-by: Kumar Piyush <kr.piyush888@gmail.com>
…is used Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
deddf74 to
884f847
Compare
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
matheuscscp
approved these changes
Jun 24, 2026
Member
There was a problem hiding this comment.
LGTM! 🚀
Thanks very much @vocarista! I had to fast-forward things here a little bit since we're very close to the Flux 2.9 release (Mon/Tue next week), so I wanted to get this done and release source-watcher. You can continue from the flux-operator side, we don't need to rush there.
pathPattern Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
…hPattern Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of controlplaneio-fluxcd/flux-operator#421
This PR introduces the
pathPatternfeature to theArtifactGeneratorCRD to support dynamic, directory-basedExternalArtifactgeneration. This resolves the need for users to manually define anOutputArtifactfor every single directory (e.g., every app/environment in a monorepo).Example
Given a monorepo with this directory structure:
Before (static)
Each artifact must be explicitly listed. Adding a new app or environment requires updating this spec:
After (with
pathPattern)A single
pathPatternreplaces all explicit entries. Theartifactsblock uses{capture}placeholders that are expanded once per matched directory:Both specs produce the same 4
ExternalArtifactobjects in the cluster. WithpathPattern, captured variables can be used as placeholders and are injected as labels on each generatedExternalArtifact(e.g.,app: auth,env: dev).When a new directory (e.g.,
apps/payments/envs/prod/) is added to the repo, the controller automatically creates the correspondingExternalArtifact— no spec update required. Conversely, when a directory is removed, itsExternalArtifactis garbage collected.Key Features & Implementation Details:
spec.pathPatterntoArtifactGeneratorSpecand support for capture placeholders in dynamic artifact fields.@monorepo/apps/{app}/envs/{env}into regex with named capture groups to match target directories.pathPatternis defined,spec.outputArtifactsacts as a template. TheName,Copy.From, andCopy.Tofields are rendered by substituting capture placeholders (e.g.,{app}-{env}).apps/auth/envs/devchanges, only theauth-devartifact gets a new revision hash, leaving other untouched artifacts intact.Testing:
artifactgenerator_pathpattern_test.go): Covered static paths, single capture patterns, invalid formats, exact-depth boundary files, and Exclude/Strategy field preservation.artifactgenerator_controller_test.go): Covered end-to-end artifact generation, strict label assertions, unpacking and asserting against physical copy paths, garbage collection on directory deletion, and selective revision updates.