helmchart: support ExternalArtifact as a HelmChart source reference#2000
Open
QuantumRoamer wants to merge 1 commit intofluxcd:mainfrom
Open
helmchart: support ExternalArtifact as a HelmChart source reference#2000QuantumRoamer wants to merge 1 commit intofluxcd:mainfrom
QuantumRoamer wants to merge 1 commit intofluxcd:mainfrom
Conversation
0a8aa46 to
1eae956
Compare
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>
1eae956 to
1be534a
Compare
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. |
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.
Problem
ExternalArtifactwas introduced as a first-class source kind in v1.7.0, but it was never wired into theHelmChartcontroller. Any attempt to reference it produces:There are three independent blocking points:
LocalHelmChartSourceReference.Kindhas a kubebuilder enum that only allowsHelmRepository,GitRepository, andBucket. A manifest withkind: ExternalArtifactis rejected at apply time.getSource()— aswitchwith adefaultcase returns the error above at reconcile time.reconcileSource()— a secondswitchwith adefaultcase returns an empty result without building the chart.Additionally, there is no
Watchesregistration forExternalArtifact, so revision changes would never trigger HelmChart reconciliation even if the above were fixed.Solution
ExternalArtifactalready satisfies theSourceinterface and exposes a tarball artifact with the same structure asBucketandGitRepository(viaGetArtifact()returning*meta.Artifact). This means the existingbuildFromTarballArtifactpath can be reused directly — no new builder code is required.This PR makes the minimum set of changes to fully unlock
ExternalArtifactas a HelmChart source.Changes
api/v1/helmchart_types.go+kubebuilder:validation:EnumonLocalHelmChartSourceReference.Kindto includeExternalArtifactinternal/controller/helmchart_controller.goWatches(&sourcev1.ExternalArtifact{}, ...)inSetupWithManagerinternal/controller/helmchart_controller.gocase sourcev1.ExternalArtifactKind:togetSource()internal/controller/helmchart_controller.gocase *sourcev1.ExternalArtifact:toreconcileSource()internal/controller/helmchart_controller.gorequestsForExternalArtifactChange()reconcile-trigger helper, mirroringrequestsForBucketChangeTesting
Both pass cleanly. I can add integration/unit tests if that would help the review — let me know the preferred approach.