Skip to content

Commit

Permalink
merge conf
Browse files Browse the repository at this point in the history
  • Loading branch information
eureka-cpu committed Dec 17, 2024
2 parents beeaf3f + 5b3873b commit 722bda8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
8 changes: 8 additions & 0 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,

#[command(flatten)]
pub shared_args: SharedDeployArgs,
}
Expand Down
14 changes: 11 additions & 3 deletions cli/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(&region)
.with_access_key_id(&access_key)
.with_secret_access_key(&secret_key)
.with_endpoint(&url)
.build()
.map_err(|err| {
BonsolCliError::S3ClientError(S3ClientError::FailedToBuildClient {
Expand All @@ -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");
Expand All @@ -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) => {
Expand Down

0 comments on commit 722bda8

Please sign in to comment.