diff --git a/src/commands/CmdSync.cpp b/src/commands/CmdSync.cpp index e90c31061..2fd38b7d4 100644 --- a/src/commands/CmdSync.cpp +++ b/src/commands/CmdSync.cpp @@ -98,9 +98,9 @@ int CmdSync::execute(std::string& output) { Context::getContext().config.get("sync.aws.secret_access_key"); std::string aws_default_credentials = Context::getContext().config.get("sync.aws.default_credentials"); - if (aws_region == "") { - throw std::string("sync.aws.region is required"); - } + std::string aws_endpoint_url = Context::getContext().config.get("sync.aws.endpoint_url"); + bool aws_force_path_style = + Context::getContext().config.getBoolean("sync.aws.force_path_style"); if (encryption_secret == "") { throw std::string("sync.encryption_secret is required"); } @@ -128,14 +128,15 @@ int CmdSync::execute(std::string& output) { if (using_profile) { replica->sync_to_aws_with_profile(aws_region, aws_bucket, aws_profile, encryption_secret, - avoid_snapshots); + avoid_snapshots, aws_endpoint_url, aws_force_path_style); } else if (using_creds) { replica->sync_to_aws_with_access_key(aws_region, aws_bucket, aws_access_key_id, aws_secret_access_key, encryption_secret, - avoid_snapshots); + avoid_snapshots, aws_endpoint_url, aws_force_path_style); } else { replica->sync_to_aws_with_default_creds(aws_region, aws_bucket, encryption_secret, - avoid_snapshots); + avoid_snapshots, aws_endpoint_url, + aws_force_path_style); } } else if (gcp_bucket != "") { diff --git a/src/taskchampion-cpp/src/lib.rs b/src/taskchampion-cpp/src/lib.rs index 45a146edc..af11d0770 100644 --- a/src/taskchampion-cpp/src/lib.rs +++ b/src/taskchampion-cpp/src/lib.rs @@ -175,6 +175,8 @@ mod ffi { profile_name: String, encryption_secret: &CxxString, avoid_snapshots: bool, + endpoint_url: String, + force_path_style: bool, ) -> Result<()>; /// Sync with a server created from `ServerConfig::Aws` using `AwsCredentials::AccessKey`. @@ -186,6 +188,8 @@ mod ffi { secret_access_key: String, encryption_secret: &CxxString, avoid_snapshots: bool, + endpoint_url: String, + force_path_style: bool, ) -> Result<()>; /// Sync with a server created from `ServerConfig::Aws` using `AwsCredentials::Default`. @@ -195,6 +199,8 @@ mod ffi { bucket: String, encryption_secret: &CxxString, avoid_snapshots: bool, + endpoint_url: String, + force_path_style: bool, ) -> Result<()>; /// Sync with a server created from `ServerConfig::Gcp`. @@ -624,12 +630,24 @@ impl Replica { profile_name: String, encryption_secret: &CxxString, avoid_snapshots: bool, + endpoint_url: String, + force_path_style: bool, ) -> Result<(), CppError> { let mut server = tc::server::ServerConfig::Aws { - region, + region: if region.is_empty() { + None + } else { + Some(region) + }, bucket, credentials: tc::server::AwsCredentials::Profile { profile_name }, encryption_secret: encryption_secret.as_bytes().to_vec(), + force_path_style: force_path_style, + endpoint_url: if endpoint_url.is_empty() { + None + } else { + Some(endpoint_url) + }, } .into_server()?; Ok(self.0.sync(&mut server, avoid_snapshots)?) @@ -643,15 +661,27 @@ impl Replica { secret_access_key: String, encryption_secret: &CxxString, avoid_snapshots: bool, + endpoint_url: String, + force_path_style: bool, ) -> Result<(), CppError> { let mut server = tc::server::ServerConfig::Aws { - region, + region: if region.is_empty() { + None + } else { + Some(region) + }, bucket, credentials: tc::server::AwsCredentials::AccessKey { access_key_id, secret_access_key, }, encryption_secret: encryption_secret.as_bytes().to_vec(), + force_path_style: force_path_style, + endpoint_url: if endpoint_url.is_empty() { + None + } else { + Some(endpoint_url) + }, } .into_server()?; Ok(self.0.sync(&mut server, avoid_snapshots)?) @@ -663,12 +693,24 @@ impl Replica { bucket: String, encryption_secret: &CxxString, avoid_snapshots: bool, + endpoint_url: String, + force_path_style: bool, ) -> Result<(), CppError> { let mut server = tc::server::ServerConfig::Aws { - region, + region: if region.is_empty() { + None + } else { + Some(region) + }, bucket, credentials: tc::server::AwsCredentials::Default, encryption_secret: encryption_secret.as_bytes().to_vec(), + force_path_style: force_path_style, + endpoint_url: if endpoint_url.is_empty() { + None + } else { + Some(endpoint_url) + }, } .into_server()?; Ok(self.0.sync(&mut server, avoid_snapshots)?)