diff --git a/cli/src/command.rs b/cli/src/command.rs index 8855ca1..3cc33af 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -78,6 +78,14 @@ pub struct S3UploadArgs { )] pub region: String, + #[arg( + help = "Specify the AWS S3 compatibility endpoint", + long, + required = false, + env = "AWS_S3_ENDPOINT" + )] + pub endpoint: Option, + #[command(flatten)] pub shared_args: SharedDeployArgs, } diff --git a/cli/src/deploy.rs b/cli/src/deploy.rs index 9f454cb..54b471c 100644 --- a/cli/src/deploy.rs +++ b/cli/src/deploy.rs @@ -52,14 +52,24 @@ pub async fn deploy(rpc_url: String, signer: Keypair, deploy_args: DeployArgs) - access_key, secret_key, region, + endpoint, .. } = s3_upload; + let dest = + object_store::path::Path::from(format!("{}-{}", manifest.name, manifest.image_id)); + + let url = endpoint.unwrap_or(format!( + "https://{}.s3.{}.amazonaws.com/{}", + bucket, region, dest + )); + let s3_client = AmazonS3Builder::new() .with_bucket_name(&bucket) .with_region(®ion) .with_access_key_id(&access_key) .with_secret_access_key(&secret_key) + .with_endpoint(&url) .build() .map_err(|err| { BonsolCliError::S3ClientError(S3ClientError::FailedToBuildClient { @@ -77,9 +87,6 @@ pub async fn deploy(rpc_url: String, signer: Keypair, deploy_args: DeployArgs) - }) })?; - let dest = - object_store::path::Path::from(format!("{}-{}", manifest.name, manifest.image_id)); - let url = format!("https://{}.s3.{}.amazonaws.com/{}", bucket, region, dest); // get the file to see if it exists if s3_client.head(&dest).await.is_ok() { bar.set_message("File already exists, skipping upload"); @@ -93,6 +100,7 @@ pub async fn deploy(rpc_url: String, signer: Keypair, deploy_args: DeployArgs) - } bar.finish_and_clear(); + println!("Uploaded to S3 url {}", url); url } DeployArgs::ShadowDrive(shadow_drive_upload) => {