@@ -191,6 +191,11 @@ fn build_oci(
191
191
192
192
let mut ctrcfg = opts. container_config . clone ( ) . unwrap_or_default ( ) ;
193
193
let mut imgcfg = oci_image:: ImageConfiguration :: default ( ) ;
194
+ // If a platform was provided, propagate it to the config
195
+ if let Some ( platform) = opts. platform . as_ref ( ) {
196
+ imgcfg. set_architecture ( platform. architecture ( ) . clone ( ) ) ;
197
+ imgcfg. set_os ( platform. os ( ) . clone ( ) ) ;
198
+ }
194
199
195
200
let created_at = opts
196
201
. created
@@ -269,6 +274,13 @@ fn build_oci(
269
274
ctrcfg. set_cmd ( Some ( cmd. clone ( ) ) ) ;
270
275
}
271
276
277
+ // Our platform uses the image config
278
+ let platform = oci_image:: PlatformBuilder :: default ( )
279
+ . architecture ( imgcfg. architecture ( ) . clone ( ) )
280
+ . os ( imgcfg. os ( ) . clone ( ) )
281
+ . build ( )
282
+ . unwrap ( ) ;
283
+
272
284
ctrcfg
273
285
. labels_mut ( )
274
286
. get_or_insert_with ( Default :: default)
@@ -277,7 +289,7 @@ fn build_oci(
277
289
let ctrcfg = writer. write_config ( imgcfg) ?;
278
290
manifest. set_config ( ctrcfg) ;
279
291
manifest. set_annotations ( Some ( labels) ) ;
280
- let platform = oci_image :: Platform :: default ( ) ;
292
+
281
293
if let Some ( tag) = tag {
282
294
writer. insert_manifest ( manifest, Some ( tag) , platform) ?;
283
295
} else {
@@ -383,6 +395,8 @@ pub struct ExportOpts<'m, 'o> {
383
395
pub legacy_version_label : bool ,
384
396
/// Image runtime configuration that will be used as a base
385
397
pub container_config : Option < oci_image:: Config > ,
398
+ /// Override the default platform
399
+ pub platform : Option < oci_image:: Platform > ,
386
400
/// A reference to the metadata for a previous build; used to optimize
387
401
/// the packing structure.
388
402
pub prior_build : Option < & ' m oci_image:: ImageManifest > ,
0 commit comments