Merge pull request #983 from fluxcd/backport-982-to-release/v1.0.x

[release/v1.0.x] Fix: Allow upgrading from v2beta1 to v2 (GA)
This commit is contained in:
souleb 2024-05-10 16:04:23 +02:00 committed by GitHub
commit 1a7e9acb3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 79 additions and 22 deletions

View File

@ -66,7 +66,7 @@ type PostRenderer struct {
// HelmReleaseSpec defines the desired state of a Helm release.
// +kubebuilder:validation:XValidation:rule="(has(self.chart) && !has(self.chartRef)) || (!has(self.chart) && has(self.chartRef))", message="either chart or chartRef must be set"
type HelmReleaseSpec struct {
// Chart defines the template of the v1beta2.HelmChart that should be created
// Chart defines the template of the v1.HelmChart that should be created
// for this HelmRelease.
// +optional
Chart *HelmChartTemplate `json:"chart,omitempty"`
@ -287,20 +287,20 @@ func (d DriftDetection) MustDetectChanges() bool {
}
// HelmChartTemplate defines the template from which the controller will
// generate a v1beta2.HelmChart object in the same namespace as the referenced
// generate a v1.HelmChart object in the same namespace as the referenced
// v1.Source.
type HelmChartTemplate struct {
// ObjectMeta holds the template for metadata like labels and annotations.
// +optional
ObjectMeta *HelmChartTemplateObjectMeta `json:"metadata,omitempty"`
// Spec holds the template for the v1beta2.HelmChartSpec for this HelmRelease.
// Spec holds the template for the v1.HelmChartSpec for this HelmRelease.
// +required
Spec HelmChartTemplateSpec `json:"spec"`
}
// HelmChartTemplateObjectMeta defines the template for the ObjectMeta of a
// v1beta2.HelmChart.
// v1.HelmChart.
type HelmChartTemplateObjectMeta struct {
// Map of string keys and values that can be used to organize and categorize
// (scope and select) objects.
@ -317,7 +317,7 @@ type HelmChartTemplateObjectMeta struct {
}
// HelmChartTemplateSpec defines the template from which the controller will
// generate a v1beta2.HelmChartSpec object.
// generate a v1.HelmChartSpec object.
type HelmChartTemplateSpec struct {
// The name or path the Helm chart is available at in the SourceRef.
// +kubebuilder:validation:MinLength=1
@ -325,7 +325,7 @@ type HelmChartTemplateSpec struct {
// +required
Chart string `json:"chart"`
// Version semver expression, ignored for charts from v1beta2.GitRepository and
// Version semver expression, ignored for charts from v1.GitRepository and
// v1beta2.Bucket sources. Defaults to latest when omitted.
// +kubebuilder:default:=*
// +optional
@ -372,7 +372,7 @@ type HelmChartTemplateSpec struct {
Verify *HelmChartTemplateVerification `json:"verify,omitempty"`
}
// GetInterval returns the configured interval for the v1beta2.HelmChart,
// GetInterval returns the configured interval for the v1.HelmChart,
// or the given default.
func (in HelmChartTemplate) GetInterval(defaultInterval metav1.Duration) metav1.Duration {
if in.Spec.Interval == nil {
@ -382,7 +382,7 @@ func (in HelmChartTemplate) GetInterval(defaultInterval metav1.Duration) metav1.
}
// GetNamespace returns the namespace targeted namespace for the
// v1beta2.HelmChart, or the given default.
// v1.HelmChart, or the given default.
func (in HelmChartTemplate) GetNamespace(defaultNamespace string) string {
if in.Spec.SourceRef.Namespace == "" {
return defaultNamespace

View File

@ -70,7 +70,15 @@ type HelmReleaseSpec struct {
// Chart defines the template of the v1beta2.HelmChart that should be created
// for this HelmRelease.
// +required
Chart HelmChartTemplate `json:"chart"`
Chart *HelmChartTemplate `json:"chart,omitempty"`
// ChartRef holds a reference to a source controller resource containing the
// Helm chart artifact.
//
// Note: this field is provisional to the v2 API, and not actively used
// by v2beta1 HelmReleases.
// +optional
ChartRef *v2.CrossNamespaceSourceReference `json:"chartRef,omitempty"`
// Interval at which to reconcile the Helm release.
// This interval is approximate and may be subject to jitter to ensure

View File

@ -208,7 +208,16 @@ func (in *HelmReleaseList) DeepCopyObject() runtime.Object {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HelmReleaseSpec) DeepCopyInto(out *HelmReleaseSpec) {
*out = *in
in.Chart.DeepCopyInto(&out.Chart)
if in.Chart != nil {
in, out := &in.Chart, &out.Chart
*out = new(HelmChartTemplate)
(*in).DeepCopyInto(*out)
}
if in.ChartRef != nil {
in, out := &in.ChartRef, &out.ChartRef
*out = new(v2.CrossNamespaceSourceReference)
**out = **in
}
out.Interval = in.Interval
if in.KubeConfig != nil {
in, out := &in.KubeConfig, &out.KubeConfig

View File

@ -85,6 +85,9 @@ type HelmReleaseSpec struct {
// ChartRef holds a reference to a source controller resource containing the
// Helm chart artifact.
//
// Note: this field is provisional to the v2 API, and not actively used
// by v2beta2 HelmReleases.
// +optional
ChartRef *CrossNamespaceSourceReference `json:"chartRef,omitempty"`

View File

@ -53,7 +53,7 @@ spec:
properties:
chart:
description: |-
Chart defines the template of the v1beta2.HelmChart that should be created
Chart defines the template of the v1.HelmChart that should be created
for this HelmRelease.
properties:
metadata:
@ -79,7 +79,7 @@ spec:
type: object
type: object
spec:
description: Spec holds the template for the v1beta2.HelmChartSpec
description: Spec holds the template for the v1.HelmChartSpec
for this HelmRelease.
properties:
chart:
@ -179,7 +179,7 @@ spec:
version:
default: '*'
description: |-
Version semver expression, ignored for charts from v1beta2.GitRepository and
Version semver expression, ignored for charts from v1.GitRepository and
v1beta2.Bucket sources. Defaults to latest when omitted.
type: string
required:
@ -1358,6 +1358,40 @@ spec:
required:
- spec
type: object
chartRef:
description: |-
ChartRef holds a reference to a source controller resource containing the
Helm chart artifact.
Note: this field is provisional to the v2 API, and not actively used
by v2beta1 HelmReleases.
properties:
apiVersion:
description: APIVersion of the referent.
type: string
kind:
description: Kind of the referent.
enum:
- OCIRepository
- HelmChart
type: string
name:
description: Name of the referent.
maxLength: 253
minLength: 1
type: string
namespace:
description: |-
Namespace of the referent, defaults to the namespace of the Kubernetes
resource object that contains the reference.
maxLength: 63
minLength: 1
type: string
required:
- kind
- name
type: object
dependsOn:
description: |-
DependsOn may contain a meta.NamespacedObjectReference slice with
@ -2121,7 +2155,6 @@ spec:
type: object
type: array
required:
- chart
- interval
type: object
status:
@ -2611,6 +2644,10 @@ spec:
description: |-
ChartRef holds a reference to a source controller resource containing the
Helm chart artifact.
Note: this field is provisional to the v2 API, and not actively used
by v2beta2 HelmReleases.
properties:
apiVersion:
description: APIVersion of the referent.

View File

@ -79,7 +79,7 @@ HelmChartTemplate
</td>
<td>
<em>(Optional)</em>
<p>Chart defines the template of the v1beta2.HelmChart that should be created
<p>Chart defines the template of the v1.HelmChart that should be created
for this HelmRelease.</p>
</td>
</tr>
@ -668,7 +668,7 @@ bool
<a href="#helm.toolkit.fluxcd.io/v2.HelmReleaseSpec">HelmReleaseSpec</a>)
</p>
<p>HelmChartTemplate defines the template from which the controller will
generate a v1beta2.HelmChart object in the same namespace as the referenced
generate a v1.HelmChart object in the same namespace as the referenced
v1.Source.</p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table">
@ -704,7 +704,7 @@ HelmChartTemplateSpec
</em>
</td>
<td>
<p>Spec holds the template for the v1beta2.HelmChartSpec for this HelmRelease.</p>
<p>Spec holds the template for the v1.HelmChartSpec for this HelmRelease.</p>
<br/>
<br/>
<table>
@ -728,7 +728,7 @@ string
</td>
<td>
<em>(Optional)</em>
<p>Version semver expression, ignored for charts from v1beta2.GitRepository and
<p>Version semver expression, ignored for charts from v1.GitRepository and
v1beta2.Bucket sources. Defaults to latest when omitted.</p>
</td>
</tr>
@ -835,7 +835,7 @@ are not verified.</p>
<a href="#helm.toolkit.fluxcd.io/v2.HelmChartTemplate">HelmChartTemplate</a>)
</p>
<p>HelmChartTemplateObjectMeta defines the template for the ObjectMeta of a
v1beta2.HelmChart.</p>
v1.HelmChart.</p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table">
<table>
@ -886,7 +886,7 @@ More info: <a href="https://kubernetes.io/docs/concepts/overview/working-with-ob
<a href="#helm.toolkit.fluxcd.io/v2.HelmChartTemplate">HelmChartTemplate</a>)
</p>
<p>HelmChartTemplateSpec defines the template from which the controller will
generate a v1beta2.HelmChartSpec object.</p>
generate a v1.HelmChartSpec object.</p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table">
<table>
@ -917,7 +917,7 @@ string
</td>
<td>
<em>(Optional)</em>
<p>Version semver expression, ignored for charts from v1beta2.GitRepository and
<p>Version semver expression, ignored for charts from v1.GitRepository and
v1beta2.Bucket sources. Defaults to latest when omitted.</p>
</td>
</tr>
@ -1089,7 +1089,7 @@ HelmChartTemplate
</td>
<td>
<em>(Optional)</em>
<p>Chart defines the template of the v1beta2.HelmChart that should be created
<p>Chart defines the template of the v1.HelmChart that should be created
for this HelmRelease.</p>
</td>
</tr>