mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-03 16:17:19 +02:00
Add support for s3-compatible storage
This commit is contained in:
parent
7a5d222f90
commit
87e7d3e625
2 changed files with 52 additions and 9 deletions
|
@ -98,9 +98,10 @@ 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 +129,14 @@ 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 != "") {
|
||||
|
|
|
@ -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)?)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue