@@ -445,10 +445,19 @@ impl Client {
445
445
Ok ( ( ) )
446
446
}
447
447
448
- pub ( crate ) async fn pull_image ( & self , descriptor : & str ) -> Result < ( ) , ClientError > {
448
+ pub ( crate ) async fn pull_image (
449
+ & self ,
450
+ descriptor : & str ,
451
+ platform : Option < String > ,
452
+ ) -> Result < ( ) , ClientError > {
449
453
let pull_options = CreateImageOptionsBuilder :: new ( )
450
454
. from_image ( descriptor)
451
- . platform ( self . config . platform ( ) . unwrap_or_default ( ) )
455
+ . platform (
456
+ platform
457
+ . as_ref ( )
458
+ . map ( |s| s. as_str ( ) )
459
+ . unwrap_or_else ( || self . config . platform ( ) . unwrap_or_default ( ) ) ,
460
+ )
452
461
. build ( ) ;
453
462
454
463
let credentials = self . credentials_for_image ( descriptor) . await ;
@@ -462,7 +471,7 @@ impl Client {
462
471
Err ( BollardError :: DockerResponseServerError {
463
472
status_code : _,
464
473
message : _,
465
- } ) => {
474
+ } ) if ! matches ! ( platform . as_ref ( ) . map ( |s| s . as_str ( ) ) , Some ( "linux/amd64" ) ) => {
466
475
self . pull_image_linux_amd64 ( descriptor) . await ?;
467
476
}
468
477
_ => {
@@ -708,7 +717,7 @@ mod tests {
708
717
let config = env:: Config :: load :: < OsEnvWithPlatformLinuxAmd64 > ( ) . await ?;
709
718
let mut client = Client :: new ( ) . await ?;
710
719
client. config = config;
711
- client. pull_image ( "hello-world:latest" ) . await ?;
720
+ client. pull_image ( "hello-world:latest" , None ) . await ?;
712
721
713
722
let image = client. bollard . inspect_image ( "hello-world:latest" ) . await ?;
714
723
@@ -718,7 +727,7 @@ mod tests {
718
727
let config = env:: Config :: load :: < OsEnvWithPlatformLinux386 > ( ) . await ?;
719
728
let mut client = Client :: new ( ) . await ?;
720
729
client. config = config;
721
- client. pull_image ( "hello-world:latest" ) . await ?;
730
+ client. pull_image ( "hello-world:latest" , None ) . await ?;
722
731
723
732
let image = client. bollard . inspect_image ( "hello-world:latest" ) . await ?;
724
733
0 commit comments