@@ -445,10 +445,19 @@ impl Client {
445445 Ok ( ( ) )
446446 }
447447
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 > {
449453 let pull_options = CreateImageOptionsBuilder :: new ( )
450454 . 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+ )
452461 . build ( ) ;
453462
454463 let credentials = self . credentials_for_image ( descriptor) . await ;
@@ -462,7 +471,7 @@ impl Client {
462471 Err ( BollardError :: DockerResponseServerError {
463472 status_code : _,
464473 message : _,
465- } ) => {
474+ } ) if ! matches ! ( platform . as_ref ( ) . map ( |s| s . as_str ( ) ) , Some ( "linux/amd64" ) ) => {
466475 self . pull_image_linux_amd64 ( descriptor) . await ?;
467476 }
468477 _ => {
@@ -708,7 +717,7 @@ mod tests {
708717 let config = env:: Config :: load :: < OsEnvWithPlatformLinuxAmd64 > ( ) . await ?;
709718 let mut client = Client :: new ( ) . await ?;
710719 client. config = config;
711- client. pull_image ( "hello-world:latest" ) . await ?;
720+ client. pull_image ( "hello-world:latest" , None ) . await ?;
712721
713722 let image = client. bollard . inspect_image ( "hello-world:latest" ) . await ?;
714723
@@ -718,7 +727,7 @@ mod tests {
718727 let config = env:: Config :: load :: < OsEnvWithPlatformLinux386 > ( ) . await ?;
719728 let mut client = Client :: new ( ) . await ?;
720729 client. config = config;
721- client. pull_image ( "hello-world:latest" ) . await ?;
730+ client. pull_image ( "hello-world:latest" , None ) . await ?;
722731
723732 let image = client. bollard . inspect_image ( "hello-world:latest" ) . await ?;
724733
0 commit comments