@@ -702,14 +702,26 @@ func SyncRunResultArtifactManagerByRunID(ctx context.Context, db gorpmapper.SqlE
702
702
}
703
703
localRepository := fmt .Sprintf ("%s-%s" , artifact .RepoName , maturity )
704
704
705
- fi , err := artifactClient .GetFileInfo (artifact .RepoName , artifact .Path )
705
+ repoDetails , err := artifactClient .GetRepository (localRepository )
706
+ if err != nil {
707
+ log .Error (ctx , "unable to get repository %q fror result %s: %v" , localRepository , result .ID , err )
708
+ continue
709
+ }
710
+
711
+ // To get FileInfo for a docker image, we have to check the manifest file
712
+ filePath := artifact .Path
713
+ if repoDetails .PackageType == "docker" && ! strings .HasSuffix (filePath , "manifest.json" ) {
714
+ filePath = path .Join (filePath , "manifest.json" )
715
+ }
716
+
717
+ fi , err := artifactClient .GetFileInfo (artifact .RepoName , filePath )
706
718
if err != nil {
707
719
ctx := log .ContextWithStackTrace (ctx , err )
708
720
log .Error (ctx , "unable to get artifact info from result %s: %v" , result .ID , err )
709
721
continue
710
722
}
711
723
712
- existingProperties , err := artifactClient .GetProperties (localRepository , artifact . Path )
724
+ existingProperties , err := artifactClient .GetProperties (localRepository , filePath )
713
725
if err != nil {
714
726
ctx := log .ContextWithStackTrace (ctx , err )
715
727
log .Error (ctx , "unable to get artifact properties from result %s: %v" , result .ID , err )
@@ -754,9 +766,13 @@ func SyncRunResultArtifactManagerByRunID(ctx context.Context, db gorpmapper.SqlE
754
766
signedProps ["type" ] = artifact .RepoType
755
767
signedProps ["path" ] = artifact .Path
756
768
signedProps ["name" ] = artifact .Name
757
- signedProps ["md5" ] = fi .Checksums .Md5
758
- signedProps ["sha1" ] = fi .Checksums .Sha1
759
- signedProps ["sha256" ] = fi .Checksums .Sha256
769
+ if fi .Checksums == nil {
770
+ log .Error (ctx , "unable to get checksums for artifact %s %s" , artifact .RepoName , artifact .Path )
771
+ } else {
772
+ signedProps ["md5" ] = fi .Checksums .Md5
773
+ signedProps ["sha1" ] = fi .Checksums .Sha1
774
+ signedProps ["sha256" ] = fi .Checksums .Sha256
775
+ }
760
776
761
777
// Sign the properties with main CDS authentication key pair
762
778
signature , err := authentication .SignJWS (signedProps , time .Now (), 0 )
0 commit comments