@@ -22,12 +22,12 @@ import (
22
22
"time"
23
23
24
24
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
25
+ apimeta "k8s.io/apimachinery/pkg/api/meta"
25
26
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
26
27
"k8s.io/apimachinery/pkg/types"
27
28
28
29
"github.com/fluxcd/pkg/apis/kustomize"
29
30
"github.com/fluxcd/pkg/apis/meta"
30
- "github.com/fluxcd/pkg/runtime/dependency"
31
31
)
32
32
33
33
const HelmReleaseKind = "HelmRelease"
@@ -64,7 +64,7 @@ type PostRenderer struct {
64
64
65
65
// HelmReleaseSpec defines the desired state of a Helm release.
66
66
type HelmReleaseSpec struct {
67
- // Chart defines the template of the v1beta1 .HelmChart that should be created
67
+ // Chart defines the template of the v1beta2 .HelmChart that should be created
68
68
// for this HelmRelease.
69
69
// +required
70
70
Chart HelmChartTemplate `json:"chart"`
@@ -107,11 +107,11 @@ type HelmReleaseSpec struct {
107
107
// +optional
108
108
StorageNamespace string `json:"storageNamespace,omitempty"`
109
109
110
- // DependsOn may contain a dependency.CrossNamespaceDependencyReference slice with
110
+ // DependsOn may contain a meta.NamespacedObjectReference slice with
111
111
// references to HelmRelease resources that must be ready before this HelmRelease
112
112
// can be reconciled.
113
113
// +optional
114
- DependsOn []dependency. CrossNamespaceDependencyReference `json:"dependsOn,omitempty"`
114
+ DependsOn []meta. NamespacedObjectReference `json:"dependsOn,omitempty"`
115
115
116
116
// Timeout is the time to wait for any individual Kubernetes operation (like Jobs
117
117
// for hooks) during the performance of a Helm action. Defaults to '5m0s'.
@@ -221,32 +221,32 @@ type KubeConfig struct {
221
221
}
222
222
223
223
// HelmChartTemplate defines the template from which the controller will
224
- // generate a v1beta1 .HelmChart object in the same namespace as the referenced
225
- // v1beta1 .Source.
224
+ // generate a v1beta2 .HelmChart object in the same namespace as the referenced
225
+ // v1beta2 .Source.
226
226
type HelmChartTemplate struct {
227
- // Spec holds the template for the v1beta1 .HelmChartSpec for this HelmRelease.
227
+ // Spec holds the template for the v1beta2 .HelmChartSpec for this HelmRelease.
228
228
// +required
229
229
Spec HelmChartTemplateSpec `json:"spec"`
230
230
}
231
231
232
232
// HelmChartTemplateSpec defines the template from which the controller will
233
- // generate a v1beta1 .HelmChartSpec object.
233
+ // generate a v1beta2 .HelmChartSpec object.
234
234
type HelmChartTemplateSpec struct {
235
235
// The name or path the Helm chart is available at in the SourceRef.
236
236
// +required
237
237
Chart string `json:"chart"`
238
238
239
- // Version semver expression, ignored for charts from v1beta1 .GitRepository and
240
- // v1beta1 .Bucket sources. Defaults to latest when omitted.
239
+ // Version semver expression, ignored for charts from v1beta2 .GitRepository and
240
+ // v1beta2 .Bucket sources. Defaults to latest when omitted.
241
241
// +kubebuilder:default:=*
242
242
// +optional
243
243
Version string `json:"version,omitempty"`
244
244
245
- // The name and namespace of the v1beta1 .Source the chart is available at.
245
+ // The name and namespace of the v1beta2 .Source the chart is available at.
246
246
// +required
247
247
SourceRef CrossNamespaceObjectReference `json:"sourceRef"`
248
248
249
- // Interval at which to check the v1beta1 .Source for updates. Defaults to
249
+ // Interval at which to check the v1beta2 .Source for updates. Defaults to
250
250
// 'HelmReleaseSpec.Interval'.
251
251
// +optional
252
252
Interval * metav1.Duration `json:"interval,omitempty"`
@@ -276,7 +276,7 @@ type HelmChartTemplateSpec struct {
276
276
ValuesFile string `json:"valuesFile,omitempty"`
277
277
}
278
278
279
- // GetInterval returns the configured interval for the v1beta1 .HelmChart,
279
+ // GetInterval returns the configured interval for the v1beta2 .HelmChart,
280
280
// or the given default.
281
281
func (in HelmChartTemplate ) GetInterval (defaultInterval metav1.Duration ) metav1.Duration {
282
282
if in .Spec .Interval == nil {
@@ -286,7 +286,7 @@ func (in HelmChartTemplate) GetInterval(defaultInterval metav1.Duration) metav1.
286
286
}
287
287
288
288
// GetNamespace returns the namespace targeted namespace for the
289
- // v1beta1 .HelmChart, or the given default.
289
+ // v1beta2 .HelmChart, or the given default.
290
290
func (in HelmChartTemplate ) GetNamespace (defaultNamespace string ) string {
291
291
if in .Spec .SourceRef .Namespace == "" {
292
292
return defaultNamespace
@@ -841,23 +841,39 @@ func (in HelmReleaseStatus) GetHelmChart() (string, string) {
841
841
// 'Unknown' for meta.ProgressingReason.
842
842
func HelmReleaseProgressing (hr HelmRelease ) HelmRelease {
843
843
hr .Status .Conditions = []metav1.Condition {}
844
- meta .SetResourceCondition (& hr , meta .ReadyCondition , metav1 .ConditionUnknown , meta .ProgressingReason ,
845
- "Reconciliation in progress" )
844
+ newCondition := metav1.Condition {
845
+ Type : meta .ReadyCondition ,
846
+ Status : metav1 .ConditionUnknown ,
847
+ Reason : meta .ProgressingReason ,
848
+ Message : "Reconciliation in progress" ,
849
+ }
850
+ apimeta .SetStatusCondition (hr .GetStatusConditions (), newCondition )
846
851
resetFailureCounts (& hr )
847
852
return hr
848
853
}
849
854
850
855
// HelmReleaseNotReady registers a failed reconciliation of the given HelmRelease.
851
856
func HelmReleaseNotReady (hr HelmRelease , reason , message string ) HelmRelease {
852
- meta .SetResourceCondition (& hr , meta .ReadyCondition , metav1 .ConditionFalse , reason , message )
857
+ newCondition := metav1.Condition {
858
+ Type : meta .ReadyCondition ,
859
+ Status : metav1 .ConditionFalse ,
860
+ Reason : reason ,
861
+ Message : message ,
862
+ }
863
+ apimeta .SetStatusCondition (hr .GetStatusConditions (), newCondition )
853
864
hr .Status .Failures ++
854
865
return hr
855
866
}
856
867
857
868
// HelmReleaseReady registers a successful reconciliation of the given HelmRelease.
858
869
func HelmReleaseReady (hr HelmRelease ) HelmRelease {
859
- meta .SetResourceCondition (& hr , meta .ReadyCondition , metav1 .ConditionTrue , meta .ReconciliationSucceededReason ,
860
- "Release reconciliation succeeded" )
870
+ newCondition := metav1.Condition {
871
+ Type : meta .ReadyCondition ,
872
+ Status : metav1 .ConditionTrue ,
873
+ Reason : ReconciliationSucceededReason ,
874
+ Message : "Release reconciliation succeeded" ,
875
+ }
876
+ apimeta .SetStatusCondition (hr .GetStatusConditions (), newCondition )
861
877
hr .Status .LastAppliedRevision = hr .Status .LastAttemptedRevision
862
878
resetFailureCounts (& hr )
863
879
return hr
@@ -968,13 +984,9 @@ func (in HelmRelease) GetMaxHistory() int {
968
984
return * in .Spec .MaxHistory
969
985
}
970
986
971
- // GetDependsOn returns the types.NamespacedName of the HelmRelease, and a
972
- // dependency.CrossNamespaceDependencyReference slice it depends on.
973
- func (in HelmRelease ) GetDependsOn () (types.NamespacedName , []dependency.CrossNamespaceDependencyReference ) {
974
- return types.NamespacedName {
975
- Namespace : in .Namespace ,
976
- Name : in .Namespace ,
977
- }, in .Spec .DependsOn
987
+ // GetDependsOn returns the list of dependencies across-namespaces.
988
+ func (in HelmRelease ) GetDependsOn () []meta.NamespacedObjectReference {
989
+ return in .Spec .DependsOn
978
990
}
979
991
980
992
// GetStatusConditions returns a pointer to the Status.Conditions slice
0 commit comments