@@ -199,12 +199,10 @@ func (r *HelmReleaseReconciler) deleteHelmChart(ctx context.Context, hr *v2.Helm
199
199
// v2beta1.HelmChartTemplate of the given v2beta1.HelmRelease.
200
200
func buildHelmChartFromTemplate (hr * v2.HelmRelease ) * sourcev1b2.HelmChart {
201
201
template := hr .Spec .Chart
202
- return & sourcev1b2.HelmChart {
202
+ result := & sourcev1b2.HelmChart {
203
203
ObjectMeta : metav1.ObjectMeta {
204
- Name : hr .GetHelmChartName (),
205
- Namespace : hr .Spec .Chart .GetNamespace (hr .Namespace ),
206
- Labels : hr .Spec .Chart .ObjectMeta .Labels ,
207
- Annotations : hr .Spec .Chart .ObjectMeta .Annotations ,
204
+ Name : hr .GetHelmChartName (),
205
+ Namespace : hr .Spec .Chart .GetNamespace (hr .Namespace ),
208
206
},
209
207
Spec : sourcev1b2.HelmChartSpec {
210
208
Chart : template .Spec .Chart ,
@@ -220,6 +218,11 @@ func buildHelmChartFromTemplate(hr *v2.HelmRelease) *sourcev1b2.HelmChart {
220
218
Verify : templateVerificationToSourceVerification (template .Spec .Verify ),
221
219
},
222
220
}
221
+ if hr .Spec .Chart .ObjectMeta != nil {
222
+ result .ObjectMeta .Labels = hr .Spec .Chart .ObjectMeta .Labels
223
+ result .ObjectMeta .Annotations = hr .Spec .Chart .ObjectMeta .Annotations
224
+ }
225
+ return result
223
226
}
224
227
225
228
// helmChartRequiresUpdate compares the v2beta1.HelmChartTemplate of the
@@ -246,9 +249,9 @@ func helmChartRequiresUpdate(hr *v2.HelmRelease, chart *sourcev1b2.HelmChart) bo
246
249
return true
247
250
case template .Spec .ValuesFile != chart .Spec .ValuesFile :
248
251
return true
249
- case ! apiequality .Semantic .DeepEqual (template .ObjectMeta .Annotations , chart .Annotations ):
252
+ case template . ObjectMeta != nil && ! apiequality .Semantic .DeepEqual (template .ObjectMeta .Annotations , chart .Annotations ):
250
253
return true
251
- case ! apiequality .Semantic .DeepEqual (template .ObjectMeta .Labels , chart .Labels ):
254
+ case template . ObjectMeta != nil && ! apiequality .Semantic .DeepEqual (template .ObjectMeta .Labels , chart .Labels ):
252
255
return true
253
256
case ! reflect .DeepEqual (templateVerificationToSourceVerification (template .Spec .Verify ), chart .Spec .Verify ):
254
257
return true
0 commit comments