@@ -21,7 +21,6 @@ import (
2121 "errors"
2222 "fmt"
2323 "os"
24- "strings"
2524 "time"
2625
2726 "github.com/fluxcd/pkg/apis/meta"
@@ -257,6 +256,15 @@ func (r *HelmRepositoryOCIReconciler) reconcile(ctx context.Context, obj *source
257256}
258257
259258func (r * HelmRepositoryOCIReconciler ) reconcileSource (ctx context.Context , obj * sourcev1.HelmRepository ) (sreconcile.Result , error ) {
259+ if ! helmreg .IsOCI (obj .Spec .URL ) {
260+ e := & serror.Stalling {
261+ Err : fmt .Errorf ("the url scheme is not supported: %s" , obj .Spec .URL ),
262+ Reason : sourcev1 .URLInvalidReason ,
263+ }
264+ conditions .MarkFalse (obj , meta .ReadyCondition , e .Reason , e .Err .Error ())
265+ return sreconcile .ResultEmpty , e
266+ }
267+
260268 var loginOpts []helmreg.LoginOption
261269 // Configure any authentication related options
262270 if obj .Spec .SecretRef != nil {
@@ -292,20 +300,16 @@ func (r *HelmRepositoryOCIReconciler) reconcileSource(ctx context.Context, obj *
292300 }
293301 }
294302
295- if result , err := r .validateSource (ctx , obj , loginOpts ... ); err != nil || result == sreconcile .ResultEmpty {
296- return result , err
297- }
298-
299- return sreconcile .ResultSuccess , nil
303+ return r .validateSource (ctx , obj , loginOpts ... )
300304}
301305
302306// validateSource the HelmRepository object by checking the url and connecting to the underlying registry
303307// with he provided credentials.
304308func (r * HelmRepositoryOCIReconciler ) validateSource (ctx context.Context , obj * sourcev1.HelmRepository , logOpts ... helmreg.LoginOption ) (sreconcile.Result , error ) {
305309 registryClient , file , err := r .RegistryClientGenerator (logOpts != nil )
306310 if err != nil {
307- e := & serror.Stalling {
308- Err : fmt .Errorf ("failed to create registry client: %w" , err ),
311+ e := & serror.Event {
312+ Err : fmt .Errorf ("failed to create registry client:: %w" , err ),
309313 Reason : meta .FailedReason ,
310314 }
311315 conditions .MarkFalse (obj , meta .ReadyCondition , e .Reason , e .Err .Error ())
@@ -323,21 +327,12 @@ func (r *HelmRepositoryOCIReconciler) validateSource(ctx context.Context, obj *s
323327
324328 chartRepo , err := repository .NewOCIChartRepository (obj .Spec .URL , repository .WithOCIRegistryClient (registryClient ))
325329 if err != nil {
326- if strings .Contains (err .Error (), "parse" ) {
327- e := & serror.Stalling {
328- Err : fmt .Errorf ("failed to parse URL '%s': %w" , obj .Spec .URL , err ),
329- Reason : sourcev1 .URLInvalidReason ,
330- }
331- conditions .MarkFalse (obj , meta .ReadyCondition , e .Reason , e .Err .Error ())
332- return sreconcile .ResultEmpty , e
333- } else if strings .Contains (err .Error (), "the url scheme is not supported" ) {
334- e := & serror.Event {
335- Err : err ,
336- Reason : sourcev1 .URLInvalidReason ,
337- }
338- conditions .MarkFalse (obj , meta .ReadyCondition , e .Reason , e .Err .Error ())
339- return sreconcile .ResultEmpty , e
330+ e := & serror.Stalling {
331+ Err : fmt .Errorf ("failed to parse URL '%s': %w" , obj .Spec .URL , err ),
332+ Reason : sourcev1 .URLInvalidReason ,
340333 }
334+ conditions .MarkFalse (obj , meta .ReadyCondition , e .Reason , e .Err .Error ())
335+ return sreconcile .ResultEmpty , e
341336 }
342337
343338 // Attempt to login to the registry if credentials are provided.
0 commit comments