Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ config/crd/bases/ocirepositories.yaml
config/crd/bases/gitrepositories.yaml
config/crd/bases/buckets.yaml
config/crd/bases/externalartifacts.yaml
config/crd/bases/helmcharts.yaml

# Release manifests generated at build time
config/release/
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ SOURCE_CRD_VER=$(BUILD_DIR)/.src-crd-$(SOURCE_VER)
GITREPO_CRD ?= config/crd/bases/gitrepositories.yaml
BUCKET_CRD ?= config/crd/bases/buckets.yaml
OCIREPO_CRD ?= config/crd/bases/ocirepositories.yaml
HELMCHART_CRD ?= config/crd/bases/helmcharts.yaml
EA_CRD ?= config/crd/bases/externalartifacts.yaml

all: manager
Expand Down Expand Up @@ -65,15 +66,18 @@ $(BUCKET_CRD):
$(OCIREPO_CRD):
curl -s https://raw.githubusercontent.com/fluxcd/source-controller/${SOURCE_VER}/config/crd/bases/source.toolkit.fluxcd.io_ocirepositories.yaml -o $(OCIREPO_CRD)

$(HELMCHART_CRD):
curl -s https://raw.githubusercontent.com/fluxcd/source-controller/${SOURCE_VER}/config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml -o $(HELMCHART_CRD)

$(EA_CRD):
curl -s https://raw.githubusercontent.com/fluxcd/source-controller/${SOURCE_VER}/config/crd/bases/source.toolkit.fluxcd.io_externalartifacts.yaml -o $(EA_CRD)

# Download the CRDs the controller depends on
download-crd-deps: $(SOURCE_CRD_VER) $(GITREPO_CRD) $(BUCKET_CRD) $(OCIREPO_CRD) $(EA_CRD)
download-crd-deps: $(SOURCE_CRD_VER) $(GITREPO_CRD) $(BUCKET_CRD) $(OCIREPO_CRD) $(HELMCHART_CRD) $(EA_CRD)

# Delete the downloaded CRD dependencies.
cleanup-crd-deps:
rm -f $(GITREPO_CRD) $(BUCKET_CRD) $(OCIREPO_CRD) $(EA_CRD)
rm -f $(GITREPO_CRD) $(BUCKET_CRD) $(OCIREPO_CRD) $(HELMCHART_CRD) $(EA_CRD)

# Install CRDs into a cluster
install: manifests
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ that extends Flux with advanced source composition and decomposition patterns.
The source-watcher controller implements the [ArtifactGenerator](docs/README.md) API,
which allows Flux users to:

- 🔗 **Compose** multiple Flux sources (GitRepository, OCIRepository, Bucket) into a single deployable artifact
- 🔗 **Compose** multiple Flux sources (GitRepository, OCIRepository, Bucket, HelmChart) into a single deployable artifact
- 📦 **Decompose** monorepos into multiple independent artifacts with separate deployment lifecycles
- 🎯 **Optimize** reconciliation by only triggering updates when specific paths change
- 🏗️ **Structure** complex deployments from distributed sources maintained by different teams
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/artifactgenerator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type SourceReference struct {
Namespace string `json:"namespace,omitempty"`

// Kind of the source.
// +kubebuilder:validation:Enum=Bucket;GitRepository;OCIRepository
// +kubebuilder:validation:Enum=Bucket;GitRepository;OCIRepository;HelmChart
// +required
Kind string `json:"kind"`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ spec:
- Bucket
- GitRepository
- OCIRepository
- HelmChart
type: string
name:
description: Name of the source.
Expand Down
2 changes: 1 addition & 1 deletion config/samples/source_v1beta1_artifactgenerator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: podinfo
spec:
# Sources is a list of references to Flux source-controller resources
# (GitRepository, OCIRepository and Bucket) that will be
# (GitRepository, OCIRepository, Bucket and HelmChart) that will be
# used to generate ExternalArtifact resources.
sources:
- alias: chart
Expand Down
5 changes: 3 additions & 2 deletions docs/spec/v1beta1/artifactgenerators.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

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

Expand Down Expand Up @@ -462,3 +462,4 @@ the ArtifactGenerator name and namespace.
[gitrepository]: https://github.com/fluxcd/source-controller/blob/main/docs/spec/v1/gitrepositories.md
[ocirepository]: https://github.com/fluxcd/source-controller/blob/main/docs/spec/v1/ocirepositories.md
[bucket]: https://github.com/fluxcd/source-controller/blob/main/docs/spec/v1/buckets.md
[helmchart]: https://github.com/fluxcd/source-controller/blob/main/docs/spec/v1/helmcharts.md
10 changes: 10 additions & 0 deletions internal/controller/artifactgenerator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,16 @@ func (r *ArtifactGeneratorReconciler) observeSources(ctx context.Context,
return nil, fmt.Errorf("unable to get source '%s': %w", namespacedName, err)
}
source = &bucket
case sourcev1.HelmChartKind:
var chart sourcev1.HelmChart
err := r.Get(ctx, namespacedName, &chart)
if err != nil {
if apierrors.IsNotFound(err) {
return nil, err
}
return nil, fmt.Errorf("unable to get source '%s': %w", namespacedName, err)
}
source = &chart
default:
return nil, fmt.Errorf("source `%s` kind '%s' not supported",
src.Name, src.Kind)
Expand Down
5 changes: 5 additions & 0 deletions internal/controller/artifactgenerator_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ func (r *ArtifactGeneratorReconciler) SetupWithManager(ctx context.Context,
handler.EnqueueRequestsFromMapFunc(r.requestsForSourceChange),
builder.WithPredicates(sourceChangePredicate),
).
Watches(
&sourcev1.HelmChart{},
handler.EnqueueRequestsFromMapFunc(r.requestsForSourceChange),
builder.WithPredicates(sourceChangePredicate),
).
WithOptions(controller.Options{
RateLimiter: opts.RateLimiter,
}).
Expand Down