@@ -6099,6 +6099,12 @@ func testExportAnnotations(t *testing.T, sb integration.Sandbox) {
6099
6099
require .NoError (t , err )
6100
6100
defer c .Close ()
6101
6101
6102
+ registry , err := sb .NewRegistry ()
6103
+ if errors .Is (err , integration .ErrRequirements ) {
6104
+ t .Skip (err .Error ())
6105
+ }
6106
+ require .NoError (t , err )
6107
+
6102
6108
amd64 := platforms .MustParse ("linux/amd64" )
6103
6109
arm64 := platforms .MustParse ("linux/arm64" )
6104
6110
ps := []ocispecs.Platform {amd64 , arm64 }
@@ -6164,18 +6170,19 @@ func testExportAnnotations(t *testing.T, sb integration.Sandbox) {
6164
6170
6165
6171
// testing for image exporter
6166
6172
6167
- target := " testannotations:latest"
6173
+ target := registry + "/buildkit/ testannotations:latest"
6168
6174
6169
6175
_ , err = c .Build (sb .Context (), SolveOpt {
6170
6176
Exports : []ExportEntry {
6171
6177
{
6172
6178
Type : ExporterImage ,
6173
6179
Attrs : map [string ]string {
6174
- "name" : target ,
6175
- "annotation-index.gio" : "generic index opt" ,
6176
- "annotation-manifest.gmo" : "generic manifest opt" ,
6177
- "annotation-manifest-descriptor.gmdo" : "generic manifest descriptor opt" ,
6178
- "annotation-manifest[linux/amd64].mo" : "amd64 manifest opt" ,
6180
+ "name" : target ,
6181
+ "push" : "true" ,
6182
+ "annotation-index.gio" : "generic index opt" ,
6183
+ "annotation-manifest.gmo" : "generic manifest opt" ,
6184
+ "annotation-manifest-descriptor.gmdo" : "generic manifest descriptor opt" ,
6185
+ "annotation-manifest[linux/amd64].mo" : "amd64 manifest opt" ,
6179
6186
"annotation-manifest-descriptor[linux/amd64].mdo" : "amd64 manifest descriptor opt" ,
6180
6187
"annotation-manifest[linux/arm64].mo" : "arm64 manifest opt" ,
6181
6188
"annotation-manifest-descriptor[linux/arm64].mdo" : "arm64 manifest descriptor opt" ,
@@ -6185,53 +6192,42 @@ func testExportAnnotations(t *testing.T, sb integration.Sandbox) {
6185
6192
}, "" , frontend , nil )
6186
6193
require .NoError (t , err )
6187
6194
6188
- ctx := namespaces .WithNamespace (sb .Context (), "buildkit" )
6189
- cdAddress := sb .ContainerdAddress ()
6190
- if cdAddress != "" {
6191
- client , err := newContainerd (cdAddress )
6192
- require .NoError (t , err )
6193
- defer client .Close ()
6194
-
6195
- img , err := client .GetImage (ctx , target )
6196
- require .NoError (t , err )
6195
+ desc , provider , err := contentutil .ProviderFromRef (target )
6196
+ require .NoError (t , err )
6197
+ imgs , err := testutil .ReadImages (sb .Context (), provider , desc )
6198
+ require .NoError (t , err )
6199
+ require .Equal (t , 2 , len (imgs .Images ))
6197
6200
6198
- var index ocispecs.Index
6199
- indexBytes , err := content .ReadBlob (ctx , client .ContentStore (), img .Target ())
6200
- require .NoError (t , err )
6201
- require .NoError (t , json .Unmarshal (indexBytes , & index ))
6202
-
6203
- require .Equal (t , "generic index" , index .Annotations ["gi" ])
6204
- require .Equal (t , "generic index opt" , index .Annotations ["gio" ])
6205
- for _ , desc := range index .Manifests {
6206
- require .Equal (t , "generic manifest descriptor" , desc .Annotations ["gmd" ])
6207
- require .Equal (t , "generic manifest descriptor opt" , desc .Annotations ["gmdo" ])
6208
- switch {
6209
- case platforms .Only (amd64 ).Match (* desc .Platform ):
6210
- require .Equal (t , "amd64 manifest descriptor" , desc .Annotations ["md" ])
6211
- require .Equal (t , "amd64 manifest descriptor opt" , desc .Annotations ["mdo" ])
6212
- case platforms .Only (arm64 ).Match (* desc .Platform ):
6213
- require .Equal (t , "arm64 manifest descriptor" , desc .Annotations ["md" ])
6214
- require .Equal (t , "arm64 manifest descriptor opt" , desc .Annotations ["mdo" ])
6215
- default :
6216
- require .Fail (t , "unrecognized platform" )
6217
- }
6201
+ require .Equal (t , "generic index" , imgs .Index .Annotations ["gi" ])
6202
+ require .Equal (t , "generic index opt" , imgs .Index .Annotations ["gio" ])
6203
+ for _ , desc := range imgs .Index .Manifests {
6204
+ require .Equal (t , "generic manifest descriptor" , desc .Annotations ["gmd" ])
6205
+ require .Equal (t , "generic manifest descriptor opt" , desc .Annotations ["gmdo" ])
6206
+ switch {
6207
+ case platforms .Only (amd64 ).Match (* desc .Platform ):
6208
+ require .Equal (t , "amd64 manifest descriptor" , desc .Annotations ["md" ])
6209
+ require .Equal (t , "amd64 manifest descriptor opt" , desc .Annotations ["mdo" ])
6210
+ case platforms .Only (arm64 ).Match (* desc .Platform ):
6211
+ require .Equal (t , "arm64 manifest descriptor" , desc .Annotations ["md" ])
6212
+ require .Equal (t , "arm64 manifest descriptor opt" , desc .Annotations ["mdo" ])
6213
+ default :
6214
+ require .Fail (t , "unrecognized platform" )
6218
6215
}
6216
+ }
6219
6217
6220
- mfst , err := images .Manifest (ctx , client .ContentStore (), img .Target (), platforms .Only (amd64 ))
6221
- require .NoError (t , err )
6222
- require .Equal (t , "generic default" , mfst .Annotations ["gd" ])
6223
- require .Equal (t , "generic manifest" , mfst .Annotations ["gm" ])
6224
- require .Equal (t , "generic manifest opt" , mfst .Annotations ["gmo" ])
6225
- require .Equal (t , "amd64 manifest" , mfst .Annotations ["m" ])
6226
- require .Equal (t , "amd64 manifest opt" , mfst .Annotations ["mo" ])
6218
+ amdImage := imgs .Find (platforms .Format (amd64 ))
6219
+ require .Equal (t , "generic default" , amdImage .Manifest .Annotations ["gd" ])
6220
+ require .Equal (t , "generic manifest" , amdImage .Manifest .Annotations ["gm" ])
6221
+ require .Equal (t , "generic manifest opt" , amdImage .Manifest .Annotations ["gmo" ])
6222
+ require .Equal (t , "amd64 manifest" , amdImage .Manifest .Annotations ["m" ])
6223
+ require .Equal (t , "amd64 manifest opt" , amdImage .Manifest .Annotations ["mo" ])
6227
6224
6228
- mfst , err = images .Manifest (ctx , client .ContentStore (), img .Target (), platforms .Only (arm64 ))
6229
- require .NoError (t , err )
6230
- require .Equal (t , "generic manifest" , mfst .Annotations ["gm" ])
6231
- require .Equal (t , "generic manifest opt" , mfst .Annotations ["gmo" ])
6232
- require .Equal (t , "arm64 manifest" , mfst .Annotations ["m" ])
6233
- require .Equal (t , "arm64 manifest opt" , mfst .Annotations ["mo" ])
6234
- }
6225
+ armImage := imgs .Find (platforms .Format (arm64 ))
6226
+ require .Equal (t , "generic default" , armImage .Manifest .Annotations ["gd" ])
6227
+ require .Equal (t , "generic manifest" , armImage .Manifest .Annotations ["gm" ])
6228
+ require .Equal (t , "generic manifest opt" , armImage .Manifest .Annotations ["gmo" ])
6229
+ require .Equal (t , "arm64 manifest" , armImage .Manifest .Annotations ["m" ])
6230
+ require .Equal (t , "arm64 manifest opt" , armImage .Manifest .Annotations ["mo" ])
6235
6231
6236
6232
// testing for oci exporter
6237
6233
@@ -6313,6 +6309,12 @@ func testExportAnnotationsMediaTypes(t *testing.T, sb integration.Sandbox) {
6313
6309
require .NoError (t , err )
6314
6310
defer c .Close ()
6315
6311
6312
+ registry , err := sb .NewRegistry ()
6313
+ if errors .Is (err , integration .ErrRequirements ) {
6314
+ t .Skip (err .Error ())
6315
+ }
6316
+ require .NoError (t , err )
6317
+
6316
6318
p := platforms .DefaultSpec ()
6317
6319
ps := []ocispecs.Platform {p }
6318
6320
@@ -6365,65 +6367,53 @@ func testExportAnnotationsMediaTypes(t *testing.T, sb integration.Sandbox) {
6365
6367
return res , nil
6366
6368
}
6367
6369
6368
- target := " testannotationsmedia:1"
6370
+ target := registry + "/buildkit/ testannotationsmedia:1"
6369
6371
_ , err = c .Build (sb .Context (), SolveOpt {
6370
6372
Exports : []ExportEntry {
6371
6373
{
6372
6374
Type : ExporterImage ,
6373
6375
Attrs : map [string ]string {
6374
6376
"name" : target ,
6375
- "annotation-manifest.x" : "y" ,
6377
+ "push" : "true" ,
6378
+ "annotation-manifest.a" : "b" ,
6376
6379
},
6377
6380
},
6378
6381
},
6379
6382
}, "" , frontend , nil )
6380
6383
require .NoError (t , err )
6381
6384
6382
- target2 := "testannotationsmedia:2"
6385
+ desc , provider , err := contentutil .ProviderFromRef (target )
6386
+ require .NoError (t , err )
6387
+ imgs , err := testutil .ReadImages (sb .Context (), provider , desc )
6388
+ require .NoError (t , err )
6389
+ require .Equal (t , 1 , len (imgs .Images ))
6390
+
6391
+ target2 := registry + "/buildkit/testannotationsmedia:2"
6383
6392
_ , err = c .Build (sb .Context (), SolveOpt {
6384
6393
Exports : []ExportEntry {
6385
6394
{
6386
6395
Type : ExporterImage ,
6387
6396
Attrs : map [string ]string {
6388
6397
"name" : target2 ,
6389
- "annotation-index.x" : "y" ,
6398
+ "push" : "true" ,
6399
+ "annotation-index.c" : "d" ,
6390
6400
},
6391
6401
},
6392
6402
},
6393
6403
}, "" , frontend , nil )
6394
6404
require .NoError (t , err )
6395
6405
6396
- ctx := namespaces .WithNamespace (sb .Context (), "buildkit" )
6397
- cdAddress := sb .ContainerdAddress ()
6398
- if cdAddress != "" {
6399
- client , err := newContainerd (cdAddress )
6400
- require .NoError (t , err )
6401
- defer client .Close ()
6402
-
6403
- // test annotation in manifest
6404
- img , err := client .GetImage (ctx , target )
6405
- require .NoError (t , err )
6406
-
6407
- var index ocispecs.Index
6408
- indexBytes , err := content .ReadBlob (ctx , client .ContentStore (), img .Target ())
6409
- require .NoError (t , err )
6410
- require .NoError (t , json .Unmarshal (indexBytes , & index ))
6411
- require .Equal (t , images .MediaTypeDockerSchema2ManifestList , index .MediaType )
6412
-
6413
- mfst , err := images .Manifest (ctx , client .ContentStore (), img .Target (), platforms .Only (p ))
6414
- require .NoError (t , err )
6415
- require .Equal (t , "y" , mfst .Annotations ["x" ])
6406
+ desc , provider , err = contentutil .ProviderFromRef (target2 )
6407
+ require .NoError (t , err )
6408
+ imgs2 , err := testutil .ReadImages (sb .Context (), provider , desc )
6409
+ require .NoError (t , err )
6410
+ require .Equal (t , 1 , len (imgs2 .Images ))
6416
6411
6417
- // test annotation in index
6418
- img , err = client .GetImage (ctx , target2 )
6419
- require .NoError (t , err )
6412
+ require .Equal (t , "b" , imgs .Images [0 ].Manifest .Annotations ["a" ])
6413
+ require .Equal (t , "d" , imgs2 .Index .Annotations ["c" ])
6420
6414
6421
- indexBytes , err = content .ReadBlob (ctx , client .ContentStore (), img .Target ())
6422
- require .NoError (t , err )
6423
- require .NoError (t , json .Unmarshal (indexBytes , & index ))
6424
- require .Equal (t , ocispecs .MediaTypeImageIndex , index .MediaType )
6425
- require .Equal (t , "y" , index .Annotations ["x" ])
6426
- }
6415
+ require .Equal (t , images .MediaTypeDockerSchema2ManifestList , imgs .Index .MediaType )
6416
+ require .Equal (t , ocispecs .MediaTypeImageIndex , imgs2 .Index .MediaType )
6427
6417
}
6428
6418
6429
6419
func testExportAttestations (t * testing.T , sb integration.Sandbox ) {
0 commit comments