diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 2610cfa01..f5f7e88ac 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -61,6 +61,7 @@ jobs: run: | kubectl -n helm-system apply -f config/testdata/podinfo/ kubectl -n helm-system wait helmreleases/podinfo --for=condition=ready --timeout=4m + kubectl -n helm-system wait helmreleases/podinfo-git --for=condition=ready --timeout=4m - name: Run dependency tests run: | kubectl -n helm-system apply -f config/testdata/dependencies diff --git a/api/v2alpha1/helmrelease_types.go b/api/v2alpha1/helmrelease_types.go index d7c69431a..986110209 100644 --- a/api/v2alpha1/helmrelease_types.go +++ b/api/v2alpha1/helmrelease_types.go @@ -32,7 +32,8 @@ const HelmReleaseFinalizer = "finalizers.fluxcd.io" // HelmReleaseSpec defines the desired state of HelmRelease. type HelmReleaseSpec struct { - // Chart defines the Helm chart name, version and repository. + // Chart defines the template of the v1alpha1.HelmChart that should be created + // for this HelmRelease. // +required Chart HelmChartTemplate `json:"chart"` @@ -139,41 +140,49 @@ func (in HelmReleaseSpec) GetUninstall() Uninstall { return *in.Uninstall } -// HelmChartTemplate defines the template from which the controller -// will generate a HelmChart object in the same namespace as the HelmRepository. +// HelmChartTemplate defines the template from which the controller will generate a +// v1alpha1.HelmChart object in the same namespace as the referenced v1alpha1.Source. type HelmChartTemplate struct { - // Name of the Helm chart, as made available by the referenced Helm repository. // +required - Name string `json:"name"` + Spec HelmChartTemplateSpec `json:"spec"` +} + +type HelmChartTemplateSpec struct { + // The name or path the Helm chart is available at in the SourceRef. + // +required + Chart string `json:"chart"` - // Version semver expression, defaults to latest when omitted. + // Version semver expression, ignored for charts from GitRepository sources. + // Defaults to latest when omitted. // +optional Version string `json:"version,omitempty"` - // The name and namespace of the source HelmRepository the chart is available at. + // The name and namespace of the v1alpha1.Source the chart is available at. // +required SourceRef CrossNamespaceObjectReference `json:"sourceRef"` - // Interval at which to check the Helm repository for chart updates. + // Interval at which to check the v1alpha1.Source for updates. // Defaults to 'HelmReleaseSpec.Interval'. // +optional Interval *metav1.Duration `json:"interval,omitempty"` } -// GetInterval returns the configured interval for the HelmChart, or the given default. +// GetInterval returns the configured interval for the v1alpha1.HelmChart, +// or the given default. func (in HelmChartTemplate) GetInterval(defaultInterval metav1.Duration) metav1.Duration { - if in.Interval == nil { + if in.Spec.Interval == nil { return defaultInterval } - return *in.Interval + return *in.Spec.Interval } -// GetNamespace returns the namespace targeted namespace for the HelmChart, or the given default. +// GetNamespace returns the namespace targeted namespace for the v1alpha1.HelmChart, +// or the given default. func (in HelmChartTemplate) GetNamespace(defaultNamespace string) string { - if in.SourceRef.Namespace == "" { + if in.Spec.SourceRef.Namespace == "" { return defaultNamespace } - return in.SourceRef.Namespace + return in.Spec.SourceRef.Namespace } // DeploymentAction defines a consistent interface for Install and Upgrade. diff --git a/api/v2alpha1/reference_types.go b/api/v2alpha1/reference_types.go index 0818c6507..8195f9a5d 100644 --- a/api/v2alpha1/reference_types.go +++ b/api/v2alpha1/reference_types.go @@ -24,7 +24,7 @@ type CrossNamespaceObjectReference struct { APIVersion string `json:"apiVersion,omitempty"` // Kind of the referent. - // +kubebuilder:validation:Enum=HelmRepository + // +kubebuilder:validation:Enum=HelmRepository;GitRepository // +required Kind string `json:"kind,omitempty"` diff --git a/api/v2alpha1/zz_generated.deepcopy.go b/api/v2alpha1/zz_generated.deepcopy.go index 93b9603d3..34a678047 100644 --- a/api/v2alpha1/zz_generated.deepcopy.go +++ b/api/v2alpha1/zz_generated.deepcopy.go @@ -59,6 +59,22 @@ func (in *CrossNamespaceObjectReference) DeepCopy() *CrossNamespaceObjectReferen // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HelmChartTemplate) DeepCopyInto(out *HelmChartTemplate) { + *out = *in + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmChartTemplate. +func (in *HelmChartTemplate) DeepCopy() *HelmChartTemplate { + if in == nil { + return nil + } + out := new(HelmChartTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HelmChartTemplateSpec) DeepCopyInto(out *HelmChartTemplateSpec) { *out = *in out.SourceRef = in.SourceRef if in.Interval != nil { @@ -68,12 +84,12 @@ func (in *HelmChartTemplate) DeepCopyInto(out *HelmChartTemplate) { } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmChartTemplate. -func (in *HelmChartTemplate) DeepCopy() *HelmChartTemplate { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HelmChartTemplateSpec. +func (in *HelmChartTemplateSpec) DeepCopy() *HelmChartTemplateSpec { if in == nil { return nil } - out := new(HelmChartTemplate) + out := new(HelmChartTemplateSpec) in.DeepCopyInto(out) return out } diff --git a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml index f3e3467c3..48e9e1cf7 100644 --- a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml +++ b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml @@ -49,44 +49,51 @@ spec: description: HelmReleaseSpec defines the desired state of HelmRelease. properties: chart: - description: Chart defines the Helm chart name, version and repository. + description: Chart defines the template of the v1alpha1.HelmChart + that should be created for this HelmRelease. properties: - interval: - description: Interval at which to check the Helm repository for - chart updates. Defaults to 'HelmReleaseSpec.Interval'. - type: string - name: - description: Name of the Helm chart, as made available by the - referenced Helm repository. - type: string - sourceRef: - description: The name and namespace of the source HelmRepository - the chart is available at. + spec: properties: - apiVersion: - description: APIVersion of the referent. + chart: + description: The name or path the Helm chart is available + at in the SourceRef. type: string - kind: - description: Kind of the referent. - enum: - - HelmRepository + interval: + description: Interval at which to check the v1alpha1.Source + for updates. Defaults to 'HelmReleaseSpec.Interval'. type: string - name: - description: Name of the referent. - type: string - namespace: - description: Namespace of the referent. + sourceRef: + description: The name and namespace of the v1alpha1.Source + the chart is available at. + properties: + apiVersion: + description: APIVersion of the referent. + type: string + kind: + description: Kind of the referent. + enum: + - HelmRepository + - GitRepository + type: string + name: + description: Name of the referent. + type: string + namespace: + description: Namespace of the referent. + type: string + required: + - name + type: object + version: + description: Version semver expression, ignored for charts + from GitRepository sources. Defaults to latest when omitted. type: string required: - - name + - chart + - sourceRef type: object - version: - description: Version semver expression, defaults to latest when - omitted. - type: string required: - - name - - sourceRef + - spec type: object dependsOn: description: DependsOn may contain a list of HelmReleases that must diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml index 651ea3ab3..0b3ccc066 100644 --- a/config/default/kustomization.yaml +++ b/config/default/kustomization.yaml @@ -5,6 +5,6 @@ resources: - ../crd - ../rbac - ../manager -- github.com/fluxcd/source-controller/config//crd?ref=v0.0.9 -- github.com/fluxcd/source-controller/config//manager?ref=v0.0.9 +- github.com/fluxcd/source-controller/config//crd?ref=v0.0.13 +- github.com/fluxcd/source-controller/config//manager?ref=v0.0.13 - namespace.yaml diff --git a/config/samples/helm_v2alpha1_helmrelease.yaml b/config/samples/helm_v2alpha1_helmrelease.yaml deleted file mode 100644 index 48ae48b91..000000000 --- a/config/samples/helm_v2alpha1_helmrelease.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: helm.toolkit.fluxcd.io/v2alpha1 -kind: HelmRelease -metadata: - name: podinfo -spec: - interval: 5m - chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: podinfo - interval: 1m - test: - enable: true - rollback: - enable: true diff --git a/config/samples/helm_v2alpha1_helmrelease_gitrepository.yaml b/config/samples/helm_v2alpha1_helmrelease_gitrepository.yaml new file mode 100644 index 000000000..5bb21d618 --- /dev/null +++ b/config/samples/helm_v2alpha1_helmrelease_gitrepository.yaml @@ -0,0 +1,18 @@ +apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +kind: HelmRelease +metadata: + name: podinfo-gitrepository +spec: + interval: 5m + chart: + spec: + chart: ./charts/podinfo + sourceRef: + kind: GitRepository + name: podinfo + interval: 1m + upgrade: + remediation: + remediateLastFailure: true + test: + enable: true diff --git a/config/samples/helm_v2alpha1_helmrelease_helmrepository.yaml b/config/samples/helm_v2alpha1_helmrelease_helmrepository.yaml new file mode 100644 index 000000000..4d471fa41 --- /dev/null +++ b/config/samples/helm_v2alpha1_helmrelease_helmrepository.yaml @@ -0,0 +1,19 @@ +apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +kind: HelmRelease +metadata: + name: podinfo-helmrepository +spec: + interval: 5m + chart: + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: podinfo + interval: 1m + upgrade: + remediation: + remediateLastFailure: true + test: + enable: true diff --git a/config/samples/source_v1alpha1_gitrepository.yaml b/config/samples/source_v1alpha1_gitrepository.yaml new file mode 100644 index 000000000..33b989544 --- /dev/null +++ b/config/samples/source_v1alpha1_gitrepository.yaml @@ -0,0 +1,9 @@ +apiVersion: source.toolkit.fluxcd.io/v1alpha1 +kind: GitRepository +metadata: + name: podinfo +spec: + interval: 1m + url: https://github.com/stefanprodan/podinfo + ref: + branch: master diff --git a/config/samples/source_v1alpha1_helmchart.yaml b/config/samples/source_v1alpha1_helmrepository.yaml similarity index 100% rename from config/samples/source_v1alpha1_helmchart.yaml rename to config/samples/source_v1alpha1_helmrepository.yaml diff --git a/config/testdata/dependencies/helmrelease-backend.yaml b/config/testdata/dependencies/helmrelease-backend.yaml index 193885078..0e25a9eab 100644 --- a/config/testdata/dependencies/helmrelease-backend.yaml +++ b/config/testdata/dependencies/helmrelease-backend.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: webapp - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: webapp + interval: 1m values: service: grpcService: backend diff --git a/config/testdata/dependencies/helmrelease-frontend.yaml b/config/testdata/dependencies/helmrelease-frontend.yaml index c3507bd30..e19e7d700 100644 --- a/config/testdata/dependencies/helmrelease-frontend.yaml +++ b/config/testdata/dependencies/helmrelease-frontend.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: webapp - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: webapp + interval: 1m dependsOn: - backend values: diff --git a/config/testdata/install-fail-remediate/helmrelease.yaml b/config/testdata/install-fail-remediate/helmrelease.yaml index 84931d9dc..44a2781dc 100644 --- a/config/testdata/install-fail-remediate/helmrelease.yaml +++ b/config/testdata/install-fail-remediate/helmrelease.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: podinfo - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: podinfo + interval: 1m install: remediation: remediateLastFailure: true diff --git a/config/testdata/install-fail-retry/helmrelease.yaml b/config/testdata/install-fail-retry/helmrelease.yaml index b38f759c2..90f0f6999 100644 --- a/config/testdata/install-fail-retry/helmrelease.yaml +++ b/config/testdata/install-fail-retry/helmrelease.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: podinfo - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: podinfo + interval: 1m install: remediation: retries: 1 diff --git a/config/testdata/install-fail/helmrelease.yaml b/config/testdata/install-fail/helmrelease.yaml index d1a216796..a565bb145 100644 --- a/config/testdata/install-fail/helmrelease.yaml +++ b/config/testdata/install-fail/helmrelease.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: podinfo - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: podinfo + interval: 1m values: resources: requests: diff --git a/config/testdata/install-test-fail-ignore/helmrelease.yaml b/config/testdata/install-test-fail-ignore/helmrelease.yaml index ca4974a0b..5e0ecbe51 100644 --- a/config/testdata/install-test-fail-ignore/helmrelease.yaml +++ b/config/testdata/install-test-fail-ignore/helmrelease.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: podinfo - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: podinfo + interval: 1m test: enable: true ignoreFailures: true diff --git a/config/testdata/install-test-fail/helmrelease.yaml b/config/testdata/install-test-fail/helmrelease.yaml index 42152b5c5..df30d0a13 100644 --- a/config/testdata/install-test-fail/helmrelease.yaml +++ b/config/testdata/install-test-fail/helmrelease.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: podinfo - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: podinfo + interval: 1m test: enable: true values: diff --git a/config/testdata/podinfo/gitrepository.yaml b/config/testdata/podinfo/gitrepository.yaml new file mode 100644 index 000000000..33b989544 --- /dev/null +++ b/config/testdata/podinfo/gitrepository.yaml @@ -0,0 +1,9 @@ +apiVersion: source.toolkit.fluxcd.io/v1alpha1 +kind: GitRepository +metadata: + name: podinfo +spec: + interval: 1m + url: https://github.com/stefanprodan/podinfo + ref: + branch: master diff --git a/config/testdata/podinfo/helmrelease-git.yaml b/config/testdata/podinfo/helmrelease-git.yaml new file mode 100644 index 000000000..4aa25b791 --- /dev/null +++ b/config/testdata/podinfo/helmrelease-git.yaml @@ -0,0 +1,18 @@ +apiVersion: helm.toolkit.fluxcd.io/v2alpha1 +kind: HelmRelease +metadata: + name: podinfo-git +spec: + interval: 5m + chart: + spec: + chart: ./charts/podinfo + sourceRef: + kind: GitRepository + name: podinfo + interval: 1m + values: + resources: + requests: + cpu: 100m + memory: 64Mi diff --git a/config/testdata/podinfo/helmrelease.yaml b/config/testdata/podinfo/helmrelease.yaml index fffdadbbf..a48c2053f 100644 --- a/config/testdata/podinfo/helmrelease.yaml +++ b/config/testdata/podinfo/helmrelease.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: podinfo - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: podinfo + interval: 1m values: resources: requests: diff --git a/config/testdata/upgrade-fail-remediate-uninstall/install.yaml b/config/testdata/upgrade-fail-remediate-uninstall/install.yaml index 9a7ed56d5..faec5875d 100644 --- a/config/testdata/upgrade-fail-remediate-uninstall/install.yaml +++ b/config/testdata/upgrade-fail-remediate-uninstall/install.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: podinfo - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: podinfo + interval: 1m values: resources: requests: diff --git a/config/testdata/upgrade-fail-remediate-uninstall/upgrade.yaml b/config/testdata/upgrade-fail-remediate-uninstall/upgrade.yaml index d3e02bb8f..2789ad2f6 100644 --- a/config/testdata/upgrade-fail-remediate-uninstall/upgrade.yaml +++ b/config/testdata/upgrade-fail-remediate-uninstall/upgrade.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: podinfo - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: podinfo + interval: 1m upgrade: remediation: remediateLastFailure: true diff --git a/config/testdata/upgrade-fail-remediate/install.yaml b/config/testdata/upgrade-fail-remediate/install.yaml index 9ae8ae28c..b111f914a 100644 --- a/config/testdata/upgrade-fail-remediate/install.yaml +++ b/config/testdata/upgrade-fail-remediate/install.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: podinfo - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: podinfo + interval: 1m values: resources: requests: diff --git a/config/testdata/upgrade-fail-remediate/upgrade.yaml b/config/testdata/upgrade-fail-remediate/upgrade.yaml index 78c3c2f74..509ff2de1 100644 --- a/config/testdata/upgrade-fail-remediate/upgrade.yaml +++ b/config/testdata/upgrade-fail-remediate/upgrade.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: podinfo - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: podinfo + interval: 1m upgrade: remediation: remediateLastFailure: true diff --git a/config/testdata/upgrade-fail-retry/install.yaml b/config/testdata/upgrade-fail-retry/install.yaml index bb76d9305..50b6fa453 100644 --- a/config/testdata/upgrade-fail-retry/install.yaml +++ b/config/testdata/upgrade-fail-retry/install.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: podinfo - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: podinfo + interval: 1m values: resources: requests: diff --git a/config/testdata/upgrade-fail-retry/upgrade.yaml b/config/testdata/upgrade-fail-retry/upgrade.yaml index 6e07f3dbe..cd6849685 100644 --- a/config/testdata/upgrade-fail-retry/upgrade.yaml +++ b/config/testdata/upgrade-fail-retry/upgrade.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: podinfo - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: podinfo + interval: 1m upgrade: remediation: retries: 1 diff --git a/config/testdata/upgrade-fail/install.yaml b/config/testdata/upgrade-fail/install.yaml index 03b05b46b..a00d2453d 100644 --- a/config/testdata/upgrade-fail/install.yaml +++ b/config/testdata/upgrade-fail/install.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: podinfo - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: podinfo + interval: 1m values: resources: requests: diff --git a/config/testdata/upgrade-fail/upgrade.yaml b/config/testdata/upgrade-fail/upgrade.yaml index 785bc58c6..1ed7ba1bb 100644 --- a/config/testdata/upgrade-fail/upgrade.yaml +++ b/config/testdata/upgrade-fail/upgrade.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: podinfo - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: podinfo + interval: 1m values: resources: requests: diff --git a/config/testdata/upgrade-test-fail/install.yaml b/config/testdata/upgrade-test-fail/install.yaml index 9115a16f7..fe9b5ea1f 100644 --- a/config/testdata/upgrade-test-fail/install.yaml +++ b/config/testdata/upgrade-test-fail/install.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: podinfo - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: podinfo + interval: 1m values: resources: requests: diff --git a/config/testdata/upgrade-test-fail/upgrade.yaml b/config/testdata/upgrade-test-fail/upgrade.yaml index 19aea060e..f7c21b33c 100644 --- a/config/testdata/upgrade-test-fail/upgrade.yaml +++ b/config/testdata/upgrade-test-fail/upgrade.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: podinfo - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: podinfo + interval: 1m test: enable: true values: diff --git a/config/testdata/valuesfrom/helmrelease.yaml b/config/testdata/valuesfrom/helmrelease.yaml index 97ee9ee9b..9015132d3 100644 --- a/config/testdata/valuesfrom/helmrelease.yaml +++ b/config/testdata/valuesfrom/helmrelease.yaml @@ -5,12 +5,13 @@ metadata: spec: interval: 5m chart: - name: podinfo - version: '^4.0.0' - sourceRef: - kind: HelmRepository - name: valuesfrom - interval: 1m + spec: + chart: podinfo + version: '>=4.0.0 <5.0.0' + sourceRef: + kind: HelmRepository + name: valuesfrom + interval: 1m valuesFrom: - kind: ConfigMap name: valuesfrom-config diff --git a/controllers/helmrelease_controller.go b/controllers/helmrelease_controller.go index c81673a24..27c818879 100644 --- a/controllers/helmrelease_controller.go +++ b/controllers/helmrelease_controller.go @@ -603,10 +603,11 @@ func helmChartFromTemplate(hr v2.HelmRelease) *sourcev1.HelmChart { Namespace: hr.Spec.Chart.GetNamespace(hr.Namespace), }, Spec: sourcev1.HelmChartSpec{ - Name: template.Name, - Version: template.Version, - HelmRepositoryRef: corev1.LocalObjectReference{ - Name: template.SourceRef.Name, + Chart: template.Spec.Chart, + Version: template.Spec.Version, + SourceRef: sourcev1.LocalHelmChartSourceReference{ + Name: template.Spec.SourceRef.Name, + Kind: template.Spec.SourceRef.Kind, }, Interval: template.GetInterval(hr.Spec.Interval), }, @@ -616,11 +617,13 @@ func helmChartFromTemplate(hr v2.HelmRelease) *sourcev1.HelmChart { func helmChartRequiresUpdate(hr v2.HelmRelease, chart sourcev1.HelmChart) bool { template := hr.Spec.Chart switch { - case template.Name != chart.Spec.Name: + case template.Spec.Chart != chart.Spec.Chart: return true - case template.Version != chart.Spec.Version: + case template.Spec.Version != chart.Spec.Version: return true - case template.SourceRef.Name != chart.Spec.HelmRepositoryRef.Name: + case template.Spec.SourceRef.Name != chart.Spec.SourceRef.Name: + return true + case template.Spec.SourceRef.Kind != chart.Spec.SourceRef.Kind: return true case template.GetInterval(hr.Spec.Interval) != chart.Spec.Interval: return true diff --git a/docs/api/helmrelease.md b/docs/api/helmrelease.md index 2d7acab09..29fb332de 100644 --- a/docs/api/helmrelease.md +++ b/docs/api/helmrelease.md @@ -78,7 +78,8 @@ HelmChartTemplate
Chart defines the Helm chart name, version and repository.
+Chart defines the template of the v1alpha1.HelmChart that should be created +for this HelmRelease.
(Appears on: -HelmChartTemplate) +HelmChartTemplateSpec)
CrossNamespaceObjectReference contains enough information to let you locate the typed referenced object at cluster level.
@@ -454,8 +455,8 @@ string (Appears on: HelmReleaseSpec) -HelmChartTemplate defines the template from which the controller -will generate a HelmChart object in the same namespace as the HelmRepository.
+HelmChartTemplate defines the template from which the controller will generate a +v1alpha1.HelmChart object in the same namespace as the referenced v1alpha1.Source.
-name + spec + + +HelmChartTemplateSpec + + + |
+
+ + +
|
+
+(Appears on: +HelmChartTemplate) +
+Field | +Description | +
---|---|
+chart string |
- Name of the Helm chart, as made available by the referenced Helm repository. +The name or path the Helm chart is available at in the SourceRef. |
(Optional)
- Version semver expression, defaults to latest when omitted. +Version semver expression, ignored for charts from GitRepository sources. +Defaults to latest when omitted. |
|
- The name and namespace of the source HelmRepository the chart is available at. +The name and namespace of the v1alpha1.Source the chart is available at. |
|
(Optional)
- Interval at which to check the Helm repository for chart updates. + Interval at which to check the v1alpha1.Source for updates. Defaults to ‘HelmReleaseSpec.Interval’. |
- Chart defines the Helm chart name, version and repository. +Chart defines the template of the v1alpha1.HelmChart that should be created +for this HelmRelease. |