@@ -303,6 +303,31 @@ func testImagetoolsCreatePlatformFilter(t *testing.T, sb integration.Sandbox) {
303303 }
304304 require .NotEmpty (t , arm64Manifest .Digest )
305305
306+ cmd = buildxCmd (sb , withArgs ("imagetools" , "create" , "--dry-run" , "--platform=linux/arm64" , source ))
307+ dt , err = cmd .CombinedOutput ()
308+ require .NoError (t , err , string (dt ))
309+
310+ var dryRunIdx ocispecs.Index
311+ err = json .Unmarshal (dt , & dryRunIdx )
312+ require .NoError (t , err )
313+ require .Len (t , dryRunIdx .Manifests , 2 )
314+
315+ platformCount := 0
316+ attestationCount := 0
317+ for _ , desc := range dryRunIdx .Manifests {
318+ if desc .Annotations ["vnd.docker.reference.type" ] == "attestation-manifest" {
319+ attestationCount ++
320+ require .Equal (t , arm64Manifest .Digest .String (), desc .Annotations ["vnd.docker.reference.digest" ])
321+ continue
322+ }
323+ platformCount ++
324+ require .NotNil (t , desc .Platform )
325+ require .Equal (t , "linux/arm64" , platforms .Format (* desc .Platform ))
326+ require .Equal (t , arm64Manifest .Digest , desc .Digest )
327+ }
328+ require .Equal (t , 1 , platformCount )
329+ require .Equal (t , 1 , attestationCount )
330+
306331 target := registry + "/buildx/imtools-platform-filter-dst:latest"
307332 cmd = buildxCmd (sb , withArgs ("imagetools" , "create" , "--platform=linux/arm64" , "-t" , target , source ))
308333 dt , err = cmd .CombinedOutput ()
@@ -317,8 +342,8 @@ func testImagetoolsCreatePlatformFilter(t *testing.T, sb integration.Sandbox) {
317342 require .NoError (t , err )
318343 require .Len (t , filteredIdx .Manifests , 2 )
319344
320- platformCount : = 0
321- attestationCount : = 0
345+ platformCount = 0
346+ attestationCount = 0
322347 for _ , desc := range filteredIdx .Manifests {
323348 if desc .Annotations ["vnd.docker.reference.type" ] == "attestation-manifest" {
324349 attestationCount ++
@@ -908,16 +933,12 @@ func testImagetoolsMergeSourcesWithMode(t *testing.T, sb integration.Sandbox, mo
908933 }
909934
910935 merged := registryMerged + "/buildx/imtools-merge:latest"
911- cmd := buildxCmd (sb , withArgs ("imagetools" , "create" , "-t" , merged , src1 , src2 , src3 ))
936+ cmd := buildxCmd (sb , withArgs ("imagetools" , "create" , "--dry-run" , src1 , src2 , src3 ))
912937 dt , err := cmd .CombinedOutput ()
913938 require .NoError (t , err , string (dt ))
914939
915- cmd = buildxCmd (sb , withArgs ("imagetools" , "inspect" , merged , "--raw" ))
916- dt , err = cmd .CombinedOutput ()
917- require .NoError (t , err , string (dt ))
918-
919- var idx ocispecs.Index
920- err = json .Unmarshal (dt , & idx )
940+ var dryRunIdx ocispecs.Index
941+ err = json .Unmarshal (dt , & dryRunIdx )
921942 require .NoError (t , err )
922943
923944 expectedManifestCount := 5
@@ -930,6 +951,20 @@ func testImagetoolsMergeSourcesWithMode(t *testing.T, sb integration.Sandbox, mo
930951 expectedManifestCount = 10
931952 expectedAttestationCount = 5
932953 }
954+ assertMergedIndex (t , dryRunIdx , expectedManifestCount , expectedAttestationCount )
955+
956+ cmd = buildxCmd (sb , withArgs ("imagetools" , "create" , "-t" , merged , src1 , src2 , src3 ))
957+ dt , err = cmd .CombinedOutput ()
958+ require .NoError (t , err , string (dt ))
959+
960+ cmd = buildxCmd (sb , withArgs ("imagetools" , "inspect" , merged , "--raw" ))
961+ dt , err = cmd .CombinedOutput ()
962+ require .NoError (t , err , string (dt ))
963+
964+ var idx ocispecs.Index
965+ err = json .Unmarshal (dt , & idx )
966+ require .NoError (t , err )
967+
933968 assertMergedIndex (t , idx , expectedManifestCount , expectedAttestationCount )
934969}
935970
0 commit comments