mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-05 04:57:21 +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");
|
Context::getContext().config.get("sync.aws.secret_access_key");
|
||||||
std::string aws_default_credentials =
|
std::string aws_default_credentials =
|
||||||
Context::getContext().config.get("sync.aws.default_credentials");
|
Context::getContext().config.get("sync.aws.default_credentials");
|
||||||
if (aws_region == "") {
|
std::string aws_endpoint_url =
|
||||||
throw std::string("sync.aws.region is required");
|
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 == "") {
|
if (encryption_secret == "") {
|
||||||
throw std::string("sync.encryption_secret is required");
|
throw std::string("sync.encryption_secret is required");
|
||||||
}
|
}
|
||||||
|
@ -128,14 +129,14 @@ int CmdSync::execute(std::string& output) {
|
||||||
|
|
||||||
if (using_profile) {
|
if (using_profile) {
|
||||||
replica->sync_to_aws_with_profile(aws_region, aws_bucket, aws_profile, encryption_secret,
|
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) {
|
} else if (using_creds) {
|
||||||
replica->sync_to_aws_with_access_key(aws_region, aws_bucket, aws_access_key_id,
|
replica->sync_to_aws_with_access_key(aws_region, aws_bucket, aws_access_key_id,
|
||||||
aws_secret_access_key, encryption_secret,
|
aws_secret_access_key, encryption_secret,
|
||||||
avoid_snapshots);
|
avoid_snapshots, aws_endpoint_url, aws_force_path_style);
|
||||||
} else {
|
} else {
|
||||||
replica->sync_to_aws_with_default_creds(aws_region, aws_bucket, encryption_secret,
|
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 != "") {
|
} else if (gcp_bucket != "") {
|
||||||
|
|
|
@ -175,6 +175,8 @@ mod ffi {
|
||||||
profile_name: String,
|
profile_name: String,
|
||||||
encryption_secret: &CxxString,
|
encryption_secret: &CxxString,
|
||||||
avoid_snapshots: bool,
|
avoid_snapshots: bool,
|
||||||
|
endpoint_url: String,
|
||||||
|
force_path_style: bool,
|
||||||
) -> Result<()>;
|
) -> Result<()>;
|
||||||
|
|
||||||
/// Sync with a server created from `ServerConfig::Aws` using `AwsCredentials::AccessKey`.
|
/// Sync with a server created from `ServerConfig::Aws` using `AwsCredentials::AccessKey`.
|
||||||
|
@ -186,6 +188,8 @@ mod ffi {
|
||||||
secret_access_key: String,
|
secret_access_key: String,
|
||||||
encryption_secret: &CxxString,
|
encryption_secret: &CxxString,
|
||||||
avoid_snapshots: bool,
|
avoid_snapshots: bool,
|
||||||
|
endpoint_url: String,
|
||||||
|
force_path_style: bool,
|
||||||
) -> Result<()>;
|
) -> Result<()>;
|
||||||
|
|
||||||
/// Sync with a server created from `ServerConfig::Aws` using `AwsCredentials::Default`.
|
/// Sync with a server created from `ServerConfig::Aws` using `AwsCredentials::Default`.
|
||||||
|
@ -195,6 +199,8 @@ mod ffi {
|
||||||
bucket: String,
|
bucket: String,
|
||||||
encryption_secret: &CxxString,
|
encryption_secret: &CxxString,
|
||||||
avoid_snapshots: bool,
|
avoid_snapshots: bool,
|
||||||
|
endpoint_url: String,
|
||||||
|
force_path_style: bool,
|
||||||
) -> Result<()>;
|
) -> Result<()>;
|
||||||
|
|
||||||
/// Sync with a server created from `ServerConfig::Gcp`.
|
/// Sync with a server created from `ServerConfig::Gcp`.
|
||||||
|
@ -624,12 +630,24 @@ impl Replica {
|
||||||
profile_name: String,
|
profile_name: String,
|
||||||
encryption_secret: &CxxString,
|
encryption_secret: &CxxString,
|
||||||
avoid_snapshots: bool,
|
avoid_snapshots: bool,
|
||||||
|
endpoint_url: String,
|
||||||
|
force_path_style: bool,
|
||||||
) -> Result<(), CppError> {
|
) -> Result<(), CppError> {
|
||||||
let mut server = tc::server::ServerConfig::Aws {
|
let mut server = tc::server::ServerConfig::Aws {
|
||||||
region,
|
region: if region.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(region)
|
||||||
|
},
|
||||||
bucket,
|
bucket,
|
||||||
credentials: tc::server::AwsCredentials::Profile { profile_name },
|
credentials: tc::server::AwsCredentials::Profile { profile_name },
|
||||||
encryption_secret: encryption_secret.as_bytes().to_vec(),
|
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()?;
|
.into_server()?;
|
||||||
Ok(self.0.sync(&mut server, avoid_snapshots)?)
|
Ok(self.0.sync(&mut server, avoid_snapshots)?)
|
||||||
|
@ -643,15 +661,27 @@ impl Replica {
|
||||||
secret_access_key: String,
|
secret_access_key: String,
|
||||||
encryption_secret: &CxxString,
|
encryption_secret: &CxxString,
|
||||||
avoid_snapshots: bool,
|
avoid_snapshots: bool,
|
||||||
|
endpoint_url: String,
|
||||||
|
force_path_style: bool,
|
||||||
) -> Result<(), CppError> {
|
) -> Result<(), CppError> {
|
||||||
let mut server = tc::server::ServerConfig::Aws {
|
let mut server = tc::server::ServerConfig::Aws {
|
||||||
region,
|
region: if region.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(region)
|
||||||
|
},
|
||||||
bucket,
|
bucket,
|
||||||
credentials: tc::server::AwsCredentials::AccessKey {
|
credentials: tc::server::AwsCredentials::AccessKey {
|
||||||
access_key_id,
|
access_key_id,
|
||||||
secret_access_key,
|
secret_access_key,
|
||||||
},
|
},
|
||||||
encryption_secret: encryption_secret.as_bytes().to_vec(),
|
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()?;
|
.into_server()?;
|
||||||
Ok(self.0.sync(&mut server, avoid_snapshots)?)
|
Ok(self.0.sync(&mut server, avoid_snapshots)?)
|
||||||
|
@ -663,12 +693,24 @@ impl Replica {
|
||||||
bucket: String,
|
bucket: String,
|
||||||
encryption_secret: &CxxString,
|
encryption_secret: &CxxString,
|
||||||
avoid_snapshots: bool,
|
avoid_snapshots: bool,
|
||||||
|
endpoint_url: String,
|
||||||
|
force_path_style: bool,
|
||||||
) -> Result<(), CppError> {
|
) -> Result<(), CppError> {
|
||||||
let mut server = tc::server::ServerConfig::Aws {
|
let mut server = tc::server::ServerConfig::Aws {
|
||||||
region,
|
region: if region.is_empty() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(region)
|
||||||
|
},
|
||||||
bucket,
|
bucket,
|
||||||
credentials: tc::server::AwsCredentials::Default,
|
credentials: tc::server::AwsCredentials::Default,
|
||||||
encryption_secret: encryption_secret.as_bytes().to_vec(),
|
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()?;
|
.into_server()?;
|
||||||
Ok(self.0.sync(&mut server, avoid_snapshots)?)
|
Ok(self.0.sync(&mut server, avoid_snapshots)?)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue