@@ -611,7 +611,7 @@ func (r *OCIRepositoryReconciler) digestFromRevision(revision string) string {
611
611
// verifySignature verifies the authenticity of the given image reference URL.
612
612
// First, it tries to use a key if a Secret with a valid public key is provided.
613
613
// If not, it falls back to a keyless approach for verification.
614
- func (r * OCIRepositoryReconciler ) verifySignature (ctx context.Context , obj * ociv1.OCIRepository , url string , opt ... remote.Option ) error {
614
+ func (r * OCIRepositoryReconciler ) verifySignature (ctx context.Context , obj * ociv1.OCIRepository , ref name. Reference , opt ... remote.Option ) error {
615
615
ctxTimeout , cancel := context .WithTimeout (ctx , obj .Spec .Timeout .Duration )
616
616
defer cancel ()
617
617
@@ -622,15 +622,6 @@ func (r *OCIRepositoryReconciler) verifySignature(ctx context.Context, obj *ociv
622
622
soci .WithRemoteOptions (opt ... ),
623
623
}
624
624
625
- var nameOpts []name.Option
626
- if obj .Spec .Insecure {
627
- nameOpts = append (nameOpts , name .Insecure )
628
- }
629
- ref , err := name .ParseReference (url , nameOpts ... )
630
- if err != nil {
631
- return err
632
- }
633
-
634
625
// get the public keys from the given secret
635
626
if secretRef := obj .Spec .Verify .SecretRef ; secretRef != nil {
636
627
certSecretName := types.NamespacedName {
@@ -665,7 +656,7 @@ func (r *OCIRepositoryReconciler) verifySignature(ctx context.Context, obj *ociv
665
656
}
666
657
667
658
if ! signatureVerified {
668
- return fmt .Errorf ("no matching signatures were found for '%s'" , url )
659
+ return fmt .Errorf ("no matching signatures were found for '%s'" , ref )
669
660
}
670
661
671
662
return nil
@@ -687,20 +678,25 @@ func (r *OCIRepositoryReconciler) verifySignature(ctx context.Context, obj *ociv
687
678
return nil
688
679
}
689
680
690
- return fmt .Errorf ("no matching signatures were found for '%s'" , url )
681
+ return fmt .Errorf ("no matching signatures were found for '%s'" , ref )
691
682
}
692
683
693
684
return nil
694
685
}
695
686
696
687
// parseRepository validates and extracts the repository URL.
697
- func (r * OCIRepositoryReconciler ) parseRepository (url string ) (name.Repository , error ) {
698
- if ! strings .HasPrefix (url , ociv1 .OCIRepositoryPrefix ) {
688
+ func (r * OCIRepositoryReconciler ) parseRepository (obj * ociv1. OCIRepository ) (name.Repository , error ) {
689
+ if ! strings .HasPrefix (obj . Spec . URL , ociv1 .OCIRepositoryPrefix ) {
699
690
return name.Repository {}, fmt .Errorf ("URL must be in format 'oci://<domain>/<org>/<repo>'" )
700
691
}
701
692
702
- url = strings .TrimPrefix (url , ociv1 .OCIRepositoryPrefix )
703
- repo , err := name .NewRepository (url )
693
+ url := strings .TrimPrefix (obj .Spec .URL , ociv1 .OCIRepositoryPrefix )
694
+
695
+ options := []name.Option {}
696
+ if obj .Spec .Insecure {
697
+ options = append (options , name .Insecure )
698
+ }
699
+ repo , err := name .NewRepository (url , options ... )
704
700
if err != nil {
705
701
return name.Repository {}, err
706
702
}
@@ -715,7 +711,7 @@ func (r *OCIRepositoryReconciler) parseRepository(url string) (name.Repository,
715
711
716
712
// getArtifactRef determines which tag or revision should be used and returns the OCI artifact FQN.
717
713
func (r * OCIRepositoryReconciler ) getArtifactRef (obj * ociv1.OCIRepository , options []remote.Option ) (name.Reference , error ) {
718
- repo , err := r .parseRepository (obj . Spec . URL )
714
+ repo , err := r .parseRepository (obj )
719
715
if err != nil {
720
716
return nil , invalidOCIURLError {err }
721
717
}
0 commit comments