@@ -22,6 +22,7 @@ import (
22
22
"crypto/x509"
23
23
"errors"
24
24
"fmt"
25
+ "github.com/fluxcd/pkg/git"
25
26
"io"
26
27
"net/http"
27
28
"os"
@@ -390,7 +391,7 @@ func (r *OCIRepositoryReconciler) reconcileSource(ctx context.Context, sp *patch
390
391
return sreconcile .ResultEmpty , e
391
392
}
392
393
393
- // Get the upstream revision from the artifact digest
394
+ // Get the upstream revision from the artifact revision
394
395
revision , err := r .getRevision (url , opts .craneOpts )
395
396
if err != nil {
396
397
e := serror .NewGeneric (
@@ -405,7 +406,7 @@ func (r *OCIRepositoryReconciler) reconcileSource(ctx context.Context, sp *patch
405
406
406
407
// Mark observations about the revision on the object
407
408
defer func () {
408
- if ! obj .GetArtifact (). HasRevision (revision ) {
409
+ if obj .GetArtifact () == nil || git . TransformRevision ( obj . GetArtifact (). Revision ) != git . TransformRevision (revision ) {
409
410
message := fmt .Sprintf ("new revision '%s' for '%s'" , revision , url )
410
411
if obj .GetArtifact () != nil {
411
412
conditions .MarkTrue (obj , sourcev1 .ArtifactOutdatedCondition , "NewRevision" , message )
@@ -425,7 +426,7 @@ func (r *OCIRepositoryReconciler) reconcileSource(ctx context.Context, sp *patch
425
426
if obj .Spec .Verify == nil {
426
427
// Remove old observations if verification was disabled
427
428
conditions .Delete (obj , sourcev1 .SourceVerifiedCondition )
428
- } else if ! obj .GetArtifact (). HasRevision ( revision ) ||
429
+ } else if ( obj .GetArtifact () == nil || git . TransformRevision ( obj . GetArtifact (). Revision ) != git . TransformRevision ( revision ) ) ||
429
430
conditions .GetObservedGeneration (obj , sourcev1 .SourceVerifiedCondition ) != obj .Generation ||
430
431
conditions .IsFalse (obj , sourcev1 .SourceVerifiedCondition ) {
431
432
@@ -458,7 +459,9 @@ func (r *OCIRepositoryReconciler) reconcileSource(ctx context.Context, sp *patch
458
459
459
460
// Skip pulling if the artifact revision and the source configuration has
460
461
// not changed.
461
- if obj .GetArtifact ().HasRevision (revision ) && ! ociContentConfigChanged (obj ) {
462
+ if (obj .GetArtifact () != nil &&
463
+ git .TransformRevision (obj .GetArtifact ().Revision ) == git .TransformRevision (revision )) &&
464
+ ! ociContentConfigChanged (obj ) {
462
465
conditions .Delete (obj , sourcev1 .FetchFailedCondition )
463
466
return sreconcile .ResultSuccess , nil
464
467
}
@@ -582,7 +585,7 @@ func (r *OCIRepositoryReconciler) selectLayer(obj *sourcev1.OCIRepository, image
582
585
return blob , nil
583
586
}
584
587
585
- // getRevision fetches the upstream digest and returns the revision in the format `<tag>/<digest >`
588
+ // getRevision fetches the upstream revision and returns the revision in the format `<tag>/<revision >`
586
589
func (r * OCIRepositoryReconciler ) getRevision (url string , options []crane.Option ) (string , error ) {
587
590
ref , err := name .ParseReference (url )
588
591
if err != nil {
@@ -609,16 +612,16 @@ func (r *OCIRepositoryReconciler) getRevision(url string, options []crane.Option
609
612
return "" , err
610
613
}
611
614
612
- revision := digestHash .Hex
615
+ revision := digestHash .String ()
613
616
if repoTag != "" {
614
- revision = fmt .Sprintf ("%s/ %s" , repoTag , digestHash . Hex )
617
+ revision = fmt .Sprintf ("%s@ %s" , repoTag , revision )
615
618
}
616
619
return revision , nil
617
620
}
618
621
619
- // digestFromRevision extract the digest from the revision string
622
+ // digestFromRevision extract the revision from the revision string
620
623
func (r * OCIRepositoryReconciler ) digestFromRevision (revision string ) string {
621
- parts := strings .Split (revision , "/ " )
624
+ parts := strings .Split (revision , "@ " )
622
625
return parts [len (parts )- 1 ]
623
626
}
624
627
@@ -722,7 +725,7 @@ func (r *OCIRepositoryReconciler) parseRepositoryURL(obj *sourcev1.OCIRepository
722
725
return ref .Context ().Name (), nil
723
726
}
724
727
725
- // getArtifactURL determines which tag or digest should be used and returns the OCI artifact FQN.
728
+ // getArtifactURL determines which tag or revision should be used and returns the OCI artifact FQN.
726
729
func (r * OCIRepositoryReconciler ) getArtifactURL (obj * sourcev1.OCIRepository , options []crane.Option ) (string , error ) {
727
730
url , err := r .parseRepositoryURL (obj )
728
731
if err != nil {
@@ -967,7 +970,9 @@ func (r *OCIRepositoryReconciler) reconcileArtifact(ctx context.Context, sp *pat
967
970
}()
968
971
969
972
// The artifact is up-to-date
970
- if obj .GetArtifact ().HasRevision (artifact .Revision ) && ! ociContentConfigChanged (obj ) {
973
+ if (obj .GetArtifact () != nil &&
974
+ git .TransformRevision (obj .GetArtifact ().Revision ) == git .TransformRevision (revision )) &&
975
+ ! ociContentConfigChanged (obj ) {
971
976
r .eventLogf (ctx , obj , eventv1 .EventTypeTrace , sourcev1 .ArtifactUpToDateReason ,
972
977
"artifact up-to-date with remote revision: '%s'" , artifact .Revision )
973
978
return sreconcile .ResultSuccess , nil
@@ -1141,7 +1146,7 @@ func (r *OCIRepositoryReconciler) notify(ctx context.Context, oldObj, newObj *so
1141
1146
fmt .Sprintf ("%s/%s" , sourcev1 .GroupVersion .Group , eventv1 .MetaChecksumKey ): newObj .Status .Artifact .Checksum ,
1142
1147
}
1143
1148
if newObj .Status .Artifact .Digest != "" {
1144
- annotations [sourcev1 .GroupVersion .Group + "/digest " ] = newObj .Status .Artifact .Digest
1149
+ annotations [sourcev1 .GroupVersion .Group + "/revision " ] = newObj .Status .Artifact .Digest
1145
1150
}
1146
1151
1147
1152
var oldChecksum string
0 commit comments