@@ -16,6 +16,7 @@ pub struct BlobStoreS3 {
1616 aws_sdk_s3:: Client ,
1717 std:: pin:: Pin < Box < dyn std:: future:: Future < Output = aws_sdk_s3:: Client > + Send > > ,
1818 > ,
19+ container_name : Option < String > ,
1920}
2021
2122/// AWS S3 runtime config literal options for authentication
@@ -69,6 +70,7 @@ impl BlobStoreS3 {
6970 pub fn new (
7071 region : String ,
7172 auth_options : BlobStoreS3AuthOptions ,
73+ container_name : Option < String > ,
7274 ) -> Result < Self > {
7375 let builder = match & auth_options {
7476 BlobStoreS3AuthOptions :: RuntimeConfigValues ( config) =>
@@ -95,17 +97,19 @@ impl BlobStoreS3 {
9597 aws_sdk_s3:: Client :: new ( & sdk_config)
9698 } ) ;
9799
98- Ok ( Self { builder, client : async_once_cell:: Lazy :: from_future ( client_fut) } )
100+ Ok ( Self { builder, client : async_once_cell:: Lazy :: from_future ( client_fut) , container_name } )
99101 }
100102}
101103
102104#[ async_trait]
103105impl ContainerManager for BlobStoreS3 {
104106 async fn get ( & self , name : & str ) -> Result < Arc < dyn Container > , Error > {
105- let store = self . builder . clone ( ) . with_bucket_name ( name) . build ( ) . map_err ( |e| e. to_string ( ) ) ?;
107+ let name = self . container_name . clone ( ) . unwrap_or_else ( || name. to_owned ( ) ) ;
108+
109+ let store = self . builder . clone ( ) . with_bucket_name ( & name) . build ( ) . map_err ( |e| e. to_string ( ) ) ?;
106110
107111 Ok ( Arc :: new ( S3Container {
108- name : name . to_owned ( ) ,
112+ name,
109113 store,
110114 client : self . client . get_unpin ( ) . await . clone ( ) ,
111115 } ) )
0 commit comments