Skip to content

Commit

Permalink
Merge pull request #983 from fluxcd/backport-982-to-release/v1.0.x
Browse files Browse the repository at this point in the history
[release/v1.0.x] Fix: Allow upgrading from v2beta1 to v2 (GA)
  • Loading branch information
souleb authored May 10, 2024
2 parents c811cca + 2299ec1 commit 1a7e9ac
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 22 deletions.
16 changes: 8 additions & 8 deletions api/v2/helmrelease_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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.
Expand All @@ -317,15 +317,15 @@ 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
// +kubebuilder:validation:MaxLength=2048
// +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
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down
10 changes: 9 additions & 1 deletion api/v2beta1/helmrelease_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion api/v2beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions api/v2beta2/helmrelease_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand Down
45 changes: 41 additions & 4 deletions config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2121,7 +2155,6 @@ spec:
type: object
type: array
required:
- chart
- interval
type: object
status:
Expand Down Expand Up @@ -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.
Expand Down
16 changes: 8 additions & 8 deletions docs/api/v2/helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 1a7e9ac

Please sign in to comment.