Skip to content

Commit f1cf754

Browse files
committed
Parking commit: container name different from label
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
1 parent 3fa6bc0 commit f1cf754

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

crates/blobstore-s3/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub struct S3BlobStoreRuntimeConfig {
3131
token: Option<String>,
3232
/// The AWS region where the S3 account is located
3333
region: String,
34+
container_name: Option<String>,
3435
}
3536

3637
impl MakeBlobStore for S3BlobStore {
@@ -50,7 +51,7 @@ impl MakeBlobStore for S3BlobStore {
5051
_ => anyhow::bail!("either both of access_key and secret_key must be provided, or neither"),
5152
};
5253

53-
let blob_store = BlobStoreS3::new(runtime_config.region, auth)?;
54+
let blob_store = BlobStoreS3::new(runtime_config.region, auth, runtime_config.container_name)?;
5455
Ok(blob_store)
5556
}
5657
}

crates/blobstore-s3/src/store.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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]
103105
impl 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

Comments
 (0)