@@ -1294,7 +1294,7 @@ func initIntegrationTestConfig() *integrationTestConfig {
12941294}
12951295
12961296func meetsRequirements () bool {
1297- requiredTools := []string {"diffoci" }
1297+ requiredTools := []string {"diffoci" , "skopeo" }
12981298 hasRequirements := true
12991299 for _ , tool := range requiredTools {
13001300 _ , err := exec .LookPath (tool )
@@ -1308,20 +1308,8 @@ func meetsRequirements() bool {
13081308
13091309// containerDiff compares the container images image1 and image2.
13101310func containerDiff (t * testing.T , image1 , image2 string , flags ... string ) []byte {
1311- // workaround for container-diff OCI issue https://github.com/GoogleContainerTools/container-diff/issues/389
1312- if ! strings .HasPrefix (image1 , daemonPrefix ) {
1313- dockerPullCmd := exec .Command ("docker" , "pull" , image1 )
1314- out := RunCommand (dockerPullCmd , t )
1315- t .Logf ("docker pull cmd output for image1 = %s" , string (out ))
1316- image1 = daemonPrefix + image1
1317- }
1318-
1319- if ! strings .HasPrefix (image2 , daemonPrefix ) {
1320- dockerPullCmd := exec .Command ("docker" , "pull" , image2 )
1321- out := RunCommand (dockerPullCmd , t )
1322- t .Logf ("docker pull cmd output for image2 = %s" , string (out ))
1323- image2 = daemonPrefix + image2
1324- }
1311+ image1 = normalizeImageFormat (t , image1 )
1312+ image2 = normalizeImageFormat (t , image2 )
13251313
13261314 flags = append ([]string {"diff" }, flags ... )
13271315 flags = append (flags , image1 , image2 , "--ignore-image-name" , "--ignore-image-timestamps" )
@@ -1333,3 +1321,32 @@ func containerDiff(t *testing.T, image1, image2 string, flags ...string) []byte
13331321
13341322 return diff
13351323}
1324+
1325+ // normalizeImageFormat pulls image to the Docker daemon (if not already present)
1326+ // and converts it to Docker V2S2 format using skopeo. This ensures both images
1327+ // are in the same format before comparison, replicating the normalization that
1328+ // legacy Docker storage performs on pull.
1329+ func normalizeImageFormat (t * testing.T , image string ) string {
1330+ t .Helper ()
1331+ if ! strings .HasPrefix (image , daemonPrefix ) {
1332+ out := RunCommand (exec .Command ("docker" , "pull" , image ), t )
1333+ t .Logf ("docker pull %s: %s" , image , string (out ))
1334+ image = daemonPrefix + image
1335+ }
1336+ ref := strings .TrimPrefix (image , daemonPrefix )
1337+ taggedRef := ref
1338+ lastSlash := strings .LastIndex (ref , "/" )
1339+ if ! strings .Contains (ref [lastSlash + 1 :], ":" ) {
1340+ taggedRef = ref + ":latest"
1341+ }
1342+ normalized := taggedRef + "-v2s2"
1343+ cmd := exec .Command ("skopeo" , "copy" , "--format" , "v2s2" ,
1344+ "docker-daemon:" + taggedRef ,
1345+ "docker-daemon:" + normalized )
1346+ out , err := RunCommandWithoutTest (cmd )
1347+ t .Logf ("skopeo normalize %s: %s" , ref , string (out ))
1348+ if err != nil {
1349+ t .Fatalf ("failed to normalize image %s to v2s2: %v\n %s" , ref , err , string (out ))
1350+ }
1351+ return daemonPrefix + normalized
1352+ }
0 commit comments