@@ -40,12 +40,13 @@ import (
40
40
"k8s.io/apimachinery/pkg/types"
41
41
ctrl "sigs.k8s.io/controller-runtime"
42
42
43
- sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
43
+ sourcev1 "github.com/fluxcd/source-controller/api/v1"
44
+ sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"
44
45
45
46
v2 "github.com/fluxcd/helm-controller/api/v2beta1"
46
47
)
47
48
48
- func (r * HelmReleaseReconciler ) reconcileChart (ctx context.Context , hr * v2.HelmRelease ) (* sourcev1 .HelmChart , error ) {
49
+ func (r * HelmReleaseReconciler ) reconcileChart (ctx context.Context , hr * v2.HelmRelease ) (* sourcev1b2 .HelmChart , error ) {
49
50
chartName := types.NamespacedName {
50
51
Namespace : hr .Spec .Chart .GetNamespace (hr .Namespace ),
51
52
Name : hr .GetHelmChartName (),
@@ -67,7 +68,7 @@ func (r *HelmReleaseReconciler) reconcileChart(ctx context.Context, hr *v2.HelmR
67
68
}
68
69
69
70
// Continue with the reconciliation of the current template.
70
- var helmChart sourcev1 .HelmChart
71
+ var helmChart sourcev1b2 .HelmChart
71
72
err := r .Client .Get (ctx , chartName , & helmChart )
72
73
if err != nil && ! apierrors .IsNotFound (err ) {
73
74
return nil , err
@@ -81,7 +82,7 @@ func (r *HelmReleaseReconciler) reconcileChart(ctx context.Context, hr *v2.HelmR
81
82
hr .Status .HelmChart = chartName .String ()
82
83
return hc , nil
83
84
case helmChartRequiresUpdate (hr , & helmChart ):
84
- ctrl .LoggerFrom (ctx ).Info ("chart diverged from template" , strings .ToLower (sourcev1 .HelmChartKind ), chartName .String ())
85
+ ctrl .LoggerFrom (ctx ).Info ("chart diverged from template" , strings .ToLower (sourcev1b2 .HelmChartKind ), chartName .String ())
85
86
helmChart .Spec = hc .Spec
86
87
helmChart .Labels = hc .Labels
87
88
helmChart .Annotations = hc .Annotations
@@ -97,9 +98,9 @@ func (r *HelmReleaseReconciler) reconcileChart(ctx context.Context, hr *v2.HelmR
97
98
// getHelmChart retrieves the v1beta2.HelmChart for the given
98
99
// v2beta1.HelmRelease using the name that is advertised in the status
99
100
// object. It returns the v1beta2.HelmChart, or an error.
100
- func (r * HelmReleaseReconciler ) getHelmChart (ctx context.Context , hr * v2.HelmRelease ) (* sourcev1 .HelmChart , error ) {
101
+ func (r * HelmReleaseReconciler ) getHelmChart (ctx context.Context , hr * v2.HelmRelease ) (* sourcev1b2 .HelmChart , error ) {
101
102
namespace , name := hr .Status .GetHelmChart ()
102
- hc := & sourcev1 .HelmChart {}
103
+ hc := & sourcev1b2 .HelmChart {}
103
104
if err := r .Client .Get (ctx , types.NamespacedName {Namespace : namespace , Name : name }, hc ); err != nil {
104
105
return nil , err
105
106
}
@@ -109,7 +110,7 @@ func (r *HelmReleaseReconciler) getHelmChart(ctx context.Context, hr *v2.HelmRel
109
110
// loadHelmChart attempts to download the artifact from the provided source,
110
111
// loads it into a chart.Chart, and removes the downloaded artifact.
111
112
// It returns the loaded chart.Chart on success, or an error.
112
- func (r * HelmReleaseReconciler ) loadHelmChart (source * sourcev1 .HelmChart ) (* chart.Chart , error ) {
113
+ func (r * HelmReleaseReconciler ) loadHelmChart (source * sourcev1b2 .HelmChart ) (* chart.Chart , error ) {
113
114
f , err := os .CreateTemp ("" , fmt .Sprintf ("%s-%s-*.tgz" , source .GetNamespace (), source .GetName ()))
114
115
if err != nil {
115
116
return nil , err
@@ -174,7 +175,7 @@ func (r *HelmReleaseReconciler) deleteHelmChart(ctx context.Context, hr *v2.Helm
174
175
if hr .Status .HelmChart == "" {
175
176
return nil
176
177
}
177
- var hc sourcev1 .HelmChart
178
+ var hc sourcev1b2 .HelmChart
178
179
chartNS , chartName := hr .Status .GetHelmChart ()
179
180
err := r .Client .Get (ctx , types.NamespacedName {Namespace : chartNS , Name : chartName }, & hc )
180
181
if err != nil {
@@ -196,19 +197,19 @@ func (r *HelmReleaseReconciler) deleteHelmChart(ctx context.Context, hr *v2.Helm
196
197
197
198
// buildHelmChartFromTemplate builds a v1beta2.HelmChart from the
198
199
// v2beta1.HelmChartTemplate of the given v2beta1.HelmRelease.
199
- func buildHelmChartFromTemplate (hr * v2.HelmRelease ) * sourcev1 .HelmChart {
200
+ func buildHelmChartFromTemplate (hr * v2.HelmRelease ) * sourcev1b2 .HelmChart {
200
201
template := hr .Spec .Chart
201
- return & sourcev1 .HelmChart {
202
+ return & sourcev1b2 .HelmChart {
202
203
ObjectMeta : metav1.ObjectMeta {
203
204
Name : hr .GetHelmChartName (),
204
205
Namespace : hr .Spec .Chart .GetNamespace (hr .Namespace ),
205
206
Labels : hr .Spec .Chart .ObjectMeta .Labels ,
206
207
Annotations : hr .Spec .Chart .ObjectMeta .Annotations ,
207
208
},
208
- Spec : sourcev1 .HelmChartSpec {
209
+ Spec : sourcev1b2 .HelmChartSpec {
209
210
Chart : template .Spec .Chart ,
210
211
Version : template .Spec .Version ,
211
- SourceRef : sourcev1 .LocalHelmChartSourceReference {
212
+ SourceRef : sourcev1b2 .LocalHelmChartSourceReference {
212
213
Name : template .Spec .SourceRef .Name ,
213
214
Kind : template .Spec .SourceRef .Kind ,
214
215
},
@@ -224,7 +225,7 @@ func buildHelmChartFromTemplate(hr *v2.HelmRelease) *sourcev1.HelmChart {
224
225
// helmChartRequiresUpdate compares the v2beta1.HelmChartTemplate of the
225
226
// v2beta1.HelmRelease to the given v1beta2.HelmChart to determine if an
226
227
// update is required.
227
- func helmChartRequiresUpdate (hr * v2.HelmRelease , chart * sourcev1 .HelmChart ) bool {
228
+ func helmChartRequiresUpdate (hr * v2.HelmRelease , chart * sourcev1b2 .HelmChart ) bool {
228
229
template := hr .Spec .Chart
229
230
switch {
230
231
case template .Spec .Chart != chart .Spec .Chart :
@@ -257,12 +258,12 @@ func helmChartRequiresUpdate(hr *v2.HelmRelease, chart *sourcev1.HelmChart) bool
257
258
}
258
259
259
260
// templateVerificationToSourceVerification converts the HelmChartTemplateVerification to the OCIRepositoryVerification.
260
- func templateVerificationToSourceVerification (template * v2.HelmChartTemplateVerification ) * sourcev1 .OCIRepositoryVerification {
261
+ func templateVerificationToSourceVerification (template * v2.HelmChartTemplateVerification ) * sourcev1b2 .OCIRepositoryVerification {
261
262
if template == nil {
262
263
return nil
263
264
}
264
265
265
- return & sourcev1 .OCIRepositoryVerification {
266
+ return & sourcev1b2 .OCIRepositoryVerification {
266
267
Provider : template .Provider ,
267
268
SecretRef : template .SecretRef ,
268
269
}
0 commit comments