@@ -74,6 +74,8 @@ import (
74
74
// +kubebuilder:rbac:groups=helm.toolkit.fluxcd.io,resources=helmreleases/finalizers,verbs=get;create;update;patch;delete
75
75
// +kubebuilder:rbac:groups=source.toolkit.fluxcd.io,resources=helmcharts,verbs=get;list;watch
76
76
// +kubebuilder:rbac:groups=source.toolkit.fluxcd.io,resources=helmcharts/status,verbs=get
77
+ // +kubebuilder:rbac:groups=source.toolkit.fluxcd.io,resources=ocirepositories,verbs=get;list;watch
78
+ // +kubebuilder:rbac:groups=source.toolkit.fluxcd.io,resources=ocirepositories/status,verbs=get
77
79
// +kubebuilder:rbac:groups="",resources=events,verbs=create;patch
78
80
79
81
// HelmReleaseReconciler reconciles a HelmRelease object.
@@ -155,7 +157,7 @@ func (r *HelmReleaseReconciler) Reconcile(ctx context.Context, req ctrl.Request)
155
157
}
156
158
157
159
if ! isValidChartRef (obj ) {
158
- return ctrl.Result {}, reconcile .TerminalError (fmt .Errorf ("invalid HelmChart reference" ))
160
+ return ctrl.Result {}, reconcile .TerminalError (fmt .Errorf ("invalid Chart reference" ))
159
161
}
160
162
161
163
// Initialize the patch helper with the current version of the object.
@@ -277,7 +279,7 @@ func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context, patchHelpe
277
279
return ctrl.Result {}, reconcile .TerminalError (err )
278
280
}
279
281
280
- msg := fmt .Sprintf ("could not get HelmChart object: %s" , err .Error ())
282
+ msg := fmt .Sprintf ("could not get Source object: %s" , err .Error ())
281
283
conditions .MarkFalse (obj , meta .ReadyCondition , v2 .ArtifactFailedReason , msg )
282
284
return ctrl.Result {}, err
283
285
}
@@ -289,13 +291,13 @@ func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context, patchHelpe
289
291
// Check if the source is ready.
290
292
if ready , msg := isSourceReady (source ); ! ready {
291
293
log .Info (msg )
292
- conditions .MarkFalse (obj , meta .ReadyCondition , "HelmChartNotReady " , msg )
294
+ conditions .MarkFalse (obj , meta .ReadyCondition , "SourceNotReady " , msg )
293
295
// Do not requeue immediately, when the artifact is created
294
296
// the watcher should trigger a reconciliation.
295
297
return jitter .JitteredRequeueInterval (ctrl.Result {RequeueAfter : obj .GetRequeueAfter ()}), errWaitForChart
296
298
}
297
299
// Remove any stale corresponding Ready=False condition with Unknown.
298
- if conditions .HasAnyReason (obj , meta .ReadyCondition , "HelmChartNotReady " ) {
300
+ if conditions .HasAnyReason (obj , meta .ReadyCondition , "SourceNotReady " ) {
299
301
conditions .MarkUnknown (obj , meta .ReadyCondition , meta .ProgressingReason , "reconciliation in progress" )
300
302
}
301
303
@@ -315,7 +317,7 @@ func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context, patchHelpe
315
317
loadedChart , err := loader .SecureLoadChartFromURL (loader .NewRetryableHTTPClient (ctx , r .artifactFetchRetries ), source .GetArtifact ().URL , source .GetArtifact ().Digest )
316
318
if err != nil {
317
319
if errors .Is (err , loader .ErrFileNotFound ) {
318
- msg := fmt .Sprintf ("Chart not ready: artifact not found. Retrying in %s" , r .requeueDependency .String ())
320
+ msg := fmt .Sprintf ("Source not ready: artifact not found. Retrying in %s" , r .requeueDependency .String ())
319
321
conditions .MarkFalse (obj , meta .ReadyCondition , v2 .ArtifactFailedReason , msg )
320
322
log .Info (msg )
321
323
return ctrl.Result {RequeueAfter : r .requeueDependency }, errWaitForDependency
@@ -678,6 +680,9 @@ func (r *HelmReleaseReconciler) getSource(ctx context.Context, obj *v2.HelmRelea
678
680
return r .getHelmChartFromOCIRef (ctx , obj )
679
681
}
680
682
name , namespace = obj .Spec .ChartRef .Name , obj .Spec .ChartRef .Namespace
683
+ if namespace == "" {
684
+ namespace = obj .GetNamespace ()
685
+ }
681
686
} else {
682
687
namespace , name = obj .Status .GetHelmChart ()
683
688
}
@@ -696,7 +701,10 @@ func (r *HelmReleaseReconciler) getSource(ctx context.Context, obj *v2.HelmRelea
696
701
}
697
702
698
703
func (r * HelmReleaseReconciler ) getHelmChartFromOCIRef (ctx context.Context , obj * v2.HelmRelease ) (source.Source , error ) {
699
- namespace , name := obj .Spec .ChartRef .Name , obj .Spec .ChartRef .Namespace
704
+ name , namespace := obj .Spec .ChartRef .Name , obj .Spec .ChartRef .Namespace
705
+ if namespace == "" {
706
+ namespace = obj .GetNamespace ()
707
+ }
700
708
ociRepoRef := types.NamespacedName {Namespace : namespace , Name : name }
701
709
702
710
if err := intacl .AllowsAccessTo (obj , sourcev1 .OCIRepositoryKind , ociRepoRef ); err != nil {
0 commit comments