@@ -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"
@@ -257,6 +256,15 @@ func (r *HelmRepositoryOCIReconciler) reconcile(ctx context.Context, obj *source
257
256
}
258
257
259
258
func (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
+
260
268
var loginOpts []helmreg.LoginOption
261
269
// Configure any authentication related options
262
270
if obj .Spec .SecretRef != nil {
@@ -292,20 +300,16 @@ func (r *HelmRepositoryOCIReconciler) reconcileSource(ctx context.Context, obj *
292
300
}
293
301
}
294
302
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 ... )
300
304
}
301
305
302
306
// validateSource the HelmRepository object by checking the url and connecting to the underlying registry
303
307
// with he provided credentials.
304
308
func (r * HelmRepositoryOCIReconciler ) validateSource (ctx context.Context , obj * sourcev1.HelmRepository , logOpts ... helmreg.LoginOption ) (sreconcile.Result , error ) {
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