Skip to content

Commit 1526d3a

Browse files
authored
Merge pull request #982 from fluxcd/fix-upgrade
Fix: Allow upgrading from v2beta1 to v2 (GA)
2 parents bc1219f + d909c31 commit 1526d3a

File tree

6 files changed

+79
-22
lines changed

6 files changed

+79
-22
lines changed

api/v2/helmrelease_types.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ type PostRenderer struct {
6666
// HelmReleaseSpec defines the desired state of a Helm release.
6767
// +kubebuilder:validation:XValidation:rule="(has(self.chart) && !has(self.chartRef)) || (!has(self.chart) && has(self.chartRef))", message="either chart or chartRef must be set"
6868
type HelmReleaseSpec struct {
69-
// Chart defines the template of the v1beta2.HelmChart that should be created
69+
// Chart defines the template of the v1.HelmChart that should be created
7070
// for this HelmRelease.
7171
// +optional
7272
Chart *HelmChartTemplate `json:"chart,omitempty"`
@@ -287,20 +287,20 @@ func (d DriftDetection) MustDetectChanges() bool {
287287
}
288288

289289
// HelmChartTemplate defines the template from which the controller will
290-
// generate a v1beta2.HelmChart object in the same namespace as the referenced
290+
// generate a v1.HelmChart object in the same namespace as the referenced
291291
// v1.Source.
292292
type HelmChartTemplate struct {
293293
// ObjectMeta holds the template for metadata like labels and annotations.
294294
// +optional
295295
ObjectMeta *HelmChartTemplateObjectMeta `json:"metadata,omitempty"`
296296

297-
// Spec holds the template for the v1beta2.HelmChartSpec for this HelmRelease.
297+
// Spec holds the template for the v1.HelmChartSpec for this HelmRelease.
298298
// +required
299299
Spec HelmChartTemplateSpec `json:"spec"`
300300
}
301301

302302
// HelmChartTemplateObjectMeta defines the template for the ObjectMeta of a
303-
// v1beta2.HelmChart.
303+
// v1.HelmChart.
304304
type HelmChartTemplateObjectMeta struct {
305305
// Map of string keys and values that can be used to organize and categorize
306306
// (scope and select) objects.
@@ -317,15 +317,15 @@ type HelmChartTemplateObjectMeta struct {
317317
}
318318

319319
// HelmChartTemplateSpec defines the template from which the controller will
320-
// generate a v1beta2.HelmChartSpec object.
320+
// generate a v1.HelmChartSpec object.
321321
type HelmChartTemplateSpec struct {
322322
// The name or path the Helm chart is available at in the SourceRef.
323323
// +kubebuilder:validation:MinLength=1
324324
// +kubebuilder:validation:MaxLength=2048
325325
// +required
326326
Chart string `json:"chart"`
327327

328-
// Version semver expression, ignored for charts from v1beta2.GitRepository and
328+
// Version semver expression, ignored for charts from v1.GitRepository and
329329
// v1beta2.Bucket sources. Defaults to latest when omitted.
330330
// +kubebuilder:default:=*
331331
// +optional
@@ -372,7 +372,7 @@ type HelmChartTemplateSpec struct {
372372
Verify *HelmChartTemplateVerification `json:"verify,omitempty"`
373373
}
374374

375-
// GetInterval returns the configured interval for the v1beta2.HelmChart,
375+
// GetInterval returns the configured interval for the v1.HelmChart,
376376
// or the given default.
377377
func (in HelmChartTemplate) GetInterval(defaultInterval metav1.Duration) metav1.Duration {
378378
if in.Spec.Interval == nil {
@@ -382,7 +382,7 @@ func (in HelmChartTemplate) GetInterval(defaultInterval metav1.Duration) metav1.
382382
}
383383

384384
// GetNamespace returns the namespace targeted namespace for the
385-
// v1beta2.HelmChart, or the given default.
385+
// v1.HelmChart, or the given default.
386386
func (in HelmChartTemplate) GetNamespace(defaultNamespace string) string {
387387
if in.Spec.SourceRef.Namespace == "" {
388388
return defaultNamespace

api/v2beta1/helmrelease_types.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,15 @@ type HelmReleaseSpec struct {
7070
// Chart defines the template of the v1beta2.HelmChart that should be created
7171
// for this HelmRelease.
7272
// +required
73-
Chart HelmChartTemplate `json:"chart"`
73+
Chart *HelmChartTemplate `json:"chart,omitempty"`
74+
75+
// ChartRef holds a reference to a source controller resource containing the
76+
// Helm chart artifact.
77+
//
78+
// Note: this field is provisional to the v2 API, and not actively used
79+
// by v2beta1 HelmReleases.
80+
// +optional
81+
ChartRef *v2.CrossNamespaceSourceReference `json:"chartRef,omitempty"`
7482

7583
// Interval at which to reconcile the Helm release.
7684
// This interval is approximate and may be subject to jitter to ensure

api/v2beta1/zz_generated.deepcopy.go

+10-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v2beta2/helmrelease_types.go

+3
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ type HelmReleaseSpec struct {
8585

8686
// ChartRef holds a reference to a source controller resource containing the
8787
// Helm chart artifact.
88+
//
89+
// Note: this field is provisional to the v2 API, and not actively used
90+
// by v2beta2 HelmReleases.
8891
// +optional
8992
ChartRef *CrossNamespaceSourceReference `json:"chartRef,omitempty"`
9093

config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml

+41-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ spec:
5353
properties:
5454
chart:
5555
description: |-
56-
Chart defines the template of the v1beta2.HelmChart that should be created
56+
Chart defines the template of the v1.HelmChart that should be created
5757
for this HelmRelease.
5858
properties:
5959
metadata:
@@ -79,7 +79,7 @@ spec:
7979
type: object
8080
type: object
8181
spec:
82-
description: Spec holds the template for the v1beta2.HelmChartSpec
82+
description: Spec holds the template for the v1.HelmChartSpec
8383
for this HelmRelease.
8484
properties:
8585
chart:
@@ -179,7 +179,7 @@ spec:
179179
version:
180180
default: '*'
181181
description: |-
182-
Version semver expression, ignored for charts from v1beta2.GitRepository and
182+
Version semver expression, ignored for charts from v1.GitRepository and
183183
v1beta2.Bucket sources. Defaults to latest when omitted.
184184
type: string
185185
required:
@@ -1358,6 +1358,40 @@ spec:
13581358
required:
13591359
- spec
13601360
type: object
1361+
chartRef:
1362+
description: |-
1363+
ChartRef holds a reference to a source controller resource containing the
1364+
Helm chart artifact.
1365+
1366+
1367+
Note: this field is provisional to the v2 API, and not actively used
1368+
by v2beta1 HelmReleases.
1369+
properties:
1370+
apiVersion:
1371+
description: APIVersion of the referent.
1372+
type: string
1373+
kind:
1374+
description: Kind of the referent.
1375+
enum:
1376+
- OCIRepository
1377+
- HelmChart
1378+
type: string
1379+
name:
1380+
description: Name of the referent.
1381+
maxLength: 253
1382+
minLength: 1
1383+
type: string
1384+
namespace:
1385+
description: |-
1386+
Namespace of the referent, defaults to the namespace of the Kubernetes
1387+
resource object that contains the reference.
1388+
maxLength: 63
1389+
minLength: 1
1390+
type: string
1391+
required:
1392+
- kind
1393+
- name
1394+
type: object
13611395
dependsOn:
13621396
description: |-
13631397
DependsOn may contain a meta.NamespacedObjectReference slice with
@@ -2121,7 +2155,6 @@ spec:
21212155
type: object
21222156
type: array
21232157
required:
2124-
- chart
21252158
- interval
21262159
type: object
21272160
status:
@@ -2611,6 +2644,10 @@ spec:
26112644
description: |-
26122645
ChartRef holds a reference to a source controller resource containing the
26132646
Helm chart artifact.
2647+
2648+
2649+
Note: this field is provisional to the v2 API, and not actively used
2650+
by v2beta2 HelmReleases.
26142651
properties:
26152652
apiVersion:
26162653
description: APIVersion of the referent.

docs/api/v2/helm.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ HelmChartTemplate
7979
</td>
8080
<td>
8181
<em>(Optional)</em>
82-
<p>Chart defines the template of the v1beta2.HelmChart that should be created
82+
<p>Chart defines the template of the v1.HelmChart that should be created
8383
for this HelmRelease.</p>
8484
</td>
8585
</tr>
@@ -668,7 +668,7 @@ bool
668668
<a href="#helm.toolkit.fluxcd.io/v2.HelmReleaseSpec">HelmReleaseSpec</a>)
669669
</p>
670670
<p>HelmChartTemplate defines the template from which the controller will
671-
generate a v1beta2.HelmChart object in the same namespace as the referenced
671+
generate a v1.HelmChart object in the same namespace as the referenced
672672
v1.Source.</p>
673673
<div class="md-typeset__scrollwrap">
674674
<div class="md-typeset__table">
@@ -704,7 +704,7 @@ HelmChartTemplateSpec
704704
</em>
705705
</td>
706706
<td>
707-
<p>Spec holds the template for the v1beta2.HelmChartSpec for this HelmRelease.</p>
707+
<p>Spec holds the template for the v1.HelmChartSpec for this HelmRelease.</p>
708708
<br/>
709709
<br/>
710710
<table>
@@ -728,7 +728,7 @@ string
728728
</td>
729729
<td>
730730
<em>(Optional)</em>
731-
<p>Version semver expression, ignored for charts from v1beta2.GitRepository and
731+
<p>Version semver expression, ignored for charts from v1.GitRepository and
732732
v1beta2.Bucket sources. Defaults to latest when omitted.</p>
733733
</td>
734734
</tr>
@@ -835,7 +835,7 @@ are not verified.</p>
835835
<a href="#helm.toolkit.fluxcd.io/v2.HelmChartTemplate">HelmChartTemplate</a>)
836836
</p>
837837
<p>HelmChartTemplateObjectMeta defines the template for the ObjectMeta of a
838-
v1beta2.HelmChart.</p>
838+
v1.HelmChart.</p>
839839
<div class="md-typeset__scrollwrap">
840840
<div class="md-typeset__table">
841841
<table>
@@ -886,7 +886,7 @@ More info: <a href="https://kubernetes.io/docs/concepts/overview/working-with-ob
886886
<a href="#helm.toolkit.fluxcd.io/v2.HelmChartTemplate">HelmChartTemplate</a>)
887887
</p>
888888
<p>HelmChartTemplateSpec defines the template from which the controller will
889-
generate a v1beta2.HelmChartSpec object.</p>
889+
generate a v1.HelmChartSpec object.</p>
890890
<div class="md-typeset__scrollwrap">
891891
<div class="md-typeset__table">
892892
<table>
@@ -917,7 +917,7 @@ string
917917
</td>
918918
<td>
919919
<em>(Optional)</em>
920-
<p>Version semver expression, ignored for charts from v1beta2.GitRepository and
920+
<p>Version semver expression, ignored for charts from v1.GitRepository and
921921
v1beta2.Bucket sources. Defaults to latest when omitted.</p>
922922
</td>
923923
</tr>
@@ -1089,7 +1089,7 @@ HelmChartTemplate
10891089
</td>
10901090
<td>
10911091
<em>(Optional)</em>
1092-
<p>Chart defines the template of the v1beta2.HelmChart that should be created
1092+
<p>Chart defines the template of the v1.HelmChart that should be created
10931093
for this HelmRelease.</p>
10941094
</td>
10951095
</tr>

0 commit comments

Comments
 (0)