@@ -294,15 +294,21 @@ func modifyReleaseMetadataIndex(api *aws.API, rel release.Release) {
294294 }
295295
296296 var commits []release.IndexReleaseCommit
297+ var pullspecs []release.IndexReleaseOciImage
297298 for arch , vals := range rel .Architectures {
298299 commits = append (commits , release.IndexReleaseCommit {
299300 Architecture : arch ,
300301 Checksum : vals .Commit ,
301302 })
303+ pullspecs = append (pullspecs , release.IndexReleaseOciImage {
304+ Architecture : arch ,
305+ ContainerImage : * vals .OciImage ,
306+ })
302307 }
303308
304309 newIdxRelease := release.IndexRelease {
305310 Commits : commits ,
311+ OciImages : pullspecs ,
306312 Version : specVersion ,
307313 MetadataURL : url .String (),
308314 }
@@ -313,19 +319,20 @@ func modifyReleaseMetadataIndex(api *aws.API, rel release.Release) {
313319 plog .Fatalf ("build is already present and is not the latest release" )
314320 }
315321
316- comp := compareCommits (rel .Commits , newIdxRelease .Commits )
317- if comp == 0 {
322+ compCommits := compareCommits (rel .Commits , newIdxRelease .Commits )
323+ compImages := compareOciImages (rel .OciImages , newIdxRelease .OciImages )
324+ if compCommits == 0 && compImages == 0 {
318325 // the build is already the latest release, exit
319326 plog .Notice ("build is already present and is the latest release" )
320327 return
321- } else if comp == - 1 {
328+ } else if compCommits == - 1 || compImages == - 1 {
322329 // the build is present and contains a subset of the new release data,
323330 // pop the old entry and add the new version
324331 releaseIdx .Releases = releaseIdx .Releases [:len (releaseIdx .Releases )- 1 ]
325332 break
326333 } else {
327334 // the commit hash of the new build is not a superset of the current release
328- plog .Fatalf ("build is present but commit hashes are not a superset of latest release" )
335+ plog .Fatalf ("build is present but commit hashes or images are not a superset of latest release" )
329336 }
330337 }
331338 }
@@ -385,3 +392,27 @@ func compareCommits(a, b []release.IndexReleaseCommit) int {
385392 }
386393 return - 1
387394}
395+
396+ // returns -1 if a is a subset of b, 0 if equal, 1 if a is not a subset of b
397+ func compareOciImages (a , b []release.IndexReleaseOciImage ) int {
398+ if len (a ) > len (b ) {
399+ return 1
400+ }
401+ sameLength := len (a ) == len (b )
402+ for _ , aImage := range a {
403+ found := false
404+ for _ , bImage := range b {
405+ if aImage .Architecture == bImage .Architecture && aImage .ContainerImage == bImage .ContainerImage {
406+ found = true
407+ break
408+ }
409+ }
410+ if ! found {
411+ return 1
412+ }
413+ }
414+ if sameLength {
415+ return 0
416+ }
417+ return - 1
418+ }
0 commit comments