Skip to content

Commit 37a803a

Browse files
authored
Merge pull request #300 from renatovassao/rv/external-artifact-support
Add support for using ExternalArtifact as an ArtifactGenerator source.
2 parents 2512976 + d158d89 commit 37a803a

7 files changed

Lines changed: 21 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ that extends Flux with advanced source composition and decomposition patterns.
1414
The source-watcher controller implements the [ArtifactGenerator](docs/README.md) API,
1515
which allows Flux users to:
1616

17-
- 🔗 **Compose** multiple Flux sources (GitRepository, OCIRepository, Bucket, HelmChart) into a single deployable artifact
17+
- 🔗 **Compose** multiple Flux sources (GitRepository, OCIRepository, Bucket, HelmChart, ExternalArtifact) into a single deployable artifact
1818
- 📦 **Decompose** monorepos into multiple independent artifacts with separate deployment lifecycles
1919
- 🎯 **Optimize** reconciliation by only triggering updates when specific paths change
2020
- 🏗️ **Structure** complex deployments from distributed sources maintained by different teams

api/v1beta1/artifactgenerator_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ type SourceReference struct {
8383
Namespace string `json:"namespace,omitempty"`
8484

8585
// Kind of the source.
86-
// +kubebuilder:validation:Enum=Bucket;GitRepository;OCIRepository;HelmChart
86+
// +kubebuilder:validation:Enum=Bucket;GitRepository;OCIRepository;HelmChart;ExternalArtifact
8787
// +required
8888
Kind string `json:"kind"`
8989
}

config/crd/bases/source.extensions.fluxcd.io_artifactgenerators.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ spec:
159159
- GitRepository
160160
- OCIRepository
161161
- HelmChart
162+
- ExternalArtifact
162163
type: string
163164
name:
164165
description: Name of the source.

config/samples/source_v1beta1_artifactgenerator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: podinfo
55
spec:
66
# Sources is a list of references to Flux source-controller resources
7-
# (GitRepository, OCIRepository, Bucket and HelmChart) that will be
7+
# (GitRepository, OCIRepository, Bucket, HelmChart and ExternalArtifact) that will be
88
# used to generate ExternalArtifact resources.
99
sources:
1010
- alias: chart

docs/spec/v1beta1/artifactgenerators.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
The ArtifactGenerator is an extension of Flux APIs that allows source composition and decomposition.
66
It enables the generation of [ExternalArtifacts][externalartifact] from multiple sources
7-
([GitRepositories][gitrepository], [OCIRepositories][ocirepository], [Buckets][bucket] and [HelmChart][helmchart])
7+
([GitRepositories][gitrepository], [OCIRepositories][ocirepository], [Buckets][bucket], [HelmCharts][helmchart] and [ExternalArtifacts][externalartifact])
88
or the splitting of a single source into multiple artifacts.
99

1010
## Source Composition Example
@@ -203,7 +203,7 @@ for artifact generation. Each source must specify:
203203
- `alias`: A unique identifier used to reference the source in copy operations.
204204
Alias names must be unique within the same ArtifactGenerator and can only contain
205205
alphanumeric characters, dashes and underscores.
206-
- `kind`: The type of Flux source resource (`GitRepository`, `OCIRepository`, `Bucket` or `HelmChart`)
206+
- `kind`: The type of Flux source resource (`GitRepository`, `OCIRepository`, `Bucket`, `HelmChart`, or `ExternalArtifact`)
207207
- `name`: The name of the source resource
208208
- `namespace` (optional): The namespace of the source resource if different from the ArtifactGenerator namespace
209209

internal/controller/artifactgenerator_controller.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,16 @@ func (r *ArtifactGeneratorReconciler) observeSources(ctx context.Context,
318318
return nil, fmt.Errorf("unable to get source '%s': %w", namespacedName, err)
319319
}
320320
source = &chart
321+
case sourcev1.ExternalArtifactKind:
322+
var chart sourcev1.ExternalArtifact
323+
err := r.Get(ctx, namespacedName, &chart)
324+
if err != nil {
325+
if apierrors.IsNotFound(err) {
326+
return nil, err
327+
}
328+
return nil, fmt.Errorf("unable to get source '%s': %w", namespacedName, err)
329+
}
330+
source = &chart
321331
default:
322332
return nil, fmt.Errorf("source `%s` kind '%s' not supported",
323333
src.Name, src.Kind)

internal/controller/artifactgenerator_manager.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ func (r *ArtifactGeneratorReconciler) SetupWithManager(ctx context.Context,
8585
handler.EnqueueRequestsFromMapFunc(r.requestsForSourceChange),
8686
builder.WithPredicates(sourceChangePredicate),
8787
).
88+
Watches(
89+
&sourcev1.ExternalArtifact{},
90+
handler.EnqueueRequestsFromMapFunc(r.requestsForSourceChange),
91+
builder.WithPredicates(sourceChangePredicate),
92+
).
8893
WithOptions(controller.Options{
8994
RateLimiter: opts.RateLimiter,
9095
}).

0 commit comments

Comments
 (0)