@@ -702,14 +702,26 @@ func SyncRunResultArtifactManagerByRunID(ctx context.Context, db gorpmapper.SqlE
702702 }
703703 localRepository := fmt .Sprintf ("%s-%s" , artifact .RepoName , maturity )
704704
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 )
706718 if err != nil {
707719 ctx := log .ContextWithStackTrace (ctx , err )
708720 log .Error (ctx , "unable to get artifact info from result %s: %v" , result .ID , err )
709721 continue
710722 }
711723
712- existingProperties , err := artifactClient .GetProperties (localRepository , artifact . Path )
724+ existingProperties , err := artifactClient .GetProperties (localRepository , filePath )
713725 if err != nil {
714726 ctx := log .ContextWithStackTrace (ctx , err )
715727 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
754766 signedProps ["type" ] = artifact .RepoType
755767 signedProps ["path" ] = artifact .Path
756768 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+ }
760776
761777 // Sign the properties with main CDS authentication key pair
762778 signature , err := authentication .SignJWS (signedProps , time .Now (), 0 )
0 commit comments