@@ -21,7 +21,6 @@ import (
21
21
"errors"
22
22
"fmt"
23
23
"os"
24
- "strings"
25
24
"time"
26
25
27
26
"github.com/fluxcd/pkg/apis/meta"
@@ -292,20 +291,25 @@ func (r *HelmRepositoryOCIReconciler) reconcileSource(ctx context.Context, obj *
292
291
}
293
292
}
294
293
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
294
+ return r .validateSource (ctx , obj , loginOpts ... )
300
295
}
301
296
302
297
// validateSource the HelmRepository object by checking the url and connecting to the underlying registry
303
298
// with he provided credentials.
304
299
func (r * HelmRepositoryOCIReconciler ) validateSource (ctx context.Context , obj * sourcev1.HelmRepository , logOpts ... helmreg.LoginOption ) (sreconcile.Result , error ) {
300
+ if ! helmreg .IsOCI (obj .Spec .URL ) {
301
+ e := & serror.Stalling {
302
+ Err : fmt .Errorf ("the url scheme is not supported: %s" , obj .Spec .URL ),
303
+ Reason : sourcev1 .URLInvalidReason ,
304
+ }
305
+ conditions .MarkFalse (obj , meta .ReadyCondition , e .Reason , e .Err .Error ())
306
+ return sreconcile .ResultEmpty , e
307
+ }
308
+
305
309
registryClient , file , err := r .RegistryClientGenerator (logOpts != nil )
306
310
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 ),
309
313
Reason : meta .FailedReason ,
310
314
}
311
315
conditions .MarkFalse (obj , meta .ReadyCondition , e .Reason , e .Err .Error ())
@@ -323,21 +327,12 @@ func (r *HelmRepositoryOCIReconciler) validateSource(ctx context.Context, obj *s
323
327
324
328
chartRepo , err := repository .NewOCIChartRepository (obj .Spec .URL , repository .WithOCIRegistryClient (registryClient ))
325
329
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 ,
340
333
}
334
+ conditions .MarkFalse (obj , meta .ReadyCondition , e .Reason , e .Err .Error ())
335
+ return sreconcile .ResultEmpty , e
341
336
}
342
337
343
338
// Attempt to login to the registry if credentials are provided.
0 commit comments