Skip to content

helmchart: support ExternalArtifact as a HelmChart source reference#2000

Open
QuantumRoamer wants to merge 1 commit intofluxcd:mainfrom
QuantumRoamer:helmchart-external-artifact-source
Open

helmchart: support ExternalArtifact as a HelmChart source reference#2000
QuantumRoamer wants to merge 1 commit intofluxcd:mainfrom
QuantumRoamer:helmchart-external-artifact-source

Conversation

@QuantumRoamer
Copy link

@QuantumRoamer QuantumRoamer commented Mar 5, 2026

Problem

ExternalArtifact was introduced as a first-class source kind in v1.7.0, but it was never wired into the HelmChart controller. Any attempt to reference it produces:

HelmChart 'infra/infra-diagnostic-tools' is not ready: failed to get source: unsupported source kind 'ExternalArtifact', must be one of: [HelmRepository GitRepository Bucket]

There are three independent blocking points:

  1. API validationLocalHelmChartSourceReference.Kind has a kubebuilder enum that only allows HelmRepository, GitRepository, and Bucket. A manifest with kind: ExternalArtifact is rejected at apply time.
  2. getSource() — a switch with a default case returns the error above at reconcile time.
  3. reconcileSource() — a second switch with a default case returns an empty result without building the chart.

Additionally, there is no Watches registration for ExternalArtifact, so revision changes would never trigger HelmChart reconciliation even if the above were fixed.

Solution

ExternalArtifact already satisfies the Source interface and exposes a tarball artifact with the same structure as Bucket and GitRepository (via GetArtifact() returning *meta.Artifact). This means the existing buildFromTarballArtifact path can be reused directly — no new builder code is required.

This PR makes the minimum set of changes to fully unlock ExternalArtifact as a HelmChart source.

Changes

File Change
api/v1/helmchart_types.go Extend +kubebuilder:validation:Enum on LocalHelmChartSourceReference.Kind to include ExternalArtifact
internal/controller/helmchart_controller.go Register Watches(&sourcev1.ExternalArtifact{}, ...) in SetupWithManager
internal/controller/helmchart_controller.go Add case sourcev1.ExternalArtifactKind: to getSource()
internal/controller/helmchart_controller.go Add case *sourcev1.ExternalArtifact: to reconcileSource()
internal/controller/helmchart_controller.go Add requestsForExternalArtifactChange() reconcile-trigger helper, mirroring requestsForBucketChange

Testing

go build ./...
go vet ./internal/controller/...

Both pass cleanly. I can add integration/unit tests if that would help the review — let me know the preferred approach.

@QuantumRoamer QuantumRoamer changed the title helmchart: add ExternalArtifact as a valid source kind helmchart: support ExternalArtifact as a HelmChart source reference Mar 5, 2026
@QuantumRoamer QuantumRoamer force-pushed the helmchart-external-artifact-source branch 3 times, most recently from 0a8aa46 to 1eae956 Compare March 5, 2026 21:50
ExternalArtifact (source.toolkit.fluxcd.io/v1) was introduced in
v1.7.0 but was never wired into the HelmChart controller. This commit
adds the necessary plumbing so that a HelmChart can reference an
ExternalArtifact as its source, enabling advanced source-composition
patterns via the source-watcher controller.

Changes:
- Extend LocalHelmChartSourceReference.Kind enum to include ExternalArtifact
- Register a Watch for ExternalArtifact in SetupWithManager
- Add ExternalArtifactKind case to getSource()
- Add *sourcev1.ExternalArtifact case to reconcileSource()
- Add requestsForExternalArtifactChange() reconcile-trigger helper

ExternalArtifact exposes a tarball artifact identical in structure to
Bucket and GitRepository, so it reuses the existing
buildFromTarballArtifact path with no new builder code required.

Signed-off-by: Rajit Shah <rajit219@gmail.com>
@QuantumRoamer QuantumRoamer force-pushed the helmchart-external-artifact-source branch from 1eae956 to 1be534a Compare March 5, 2026 21:53
@matheuscscp
Copy link
Member

We already support this functionality here:

https://github.com/fluxcd/source-watcher/?tab=readme-ov-file#example-helm-chart-composition

Also, in source-watcher v2.1 (Flux v2.8) you can reference HelmChart as a source in ArtifactGenerator.

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.

2 participants