Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/commands/CmdSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What value does this need to take when it and aws_endpoint_url are omitted? I assume this call will default to false when the config is not provided.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll also need to update the docs as to when region is required, and allow it to be empty in other cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, this defaults to false.

I believe AWS will actually work with both aws_force_path_style = false and aws_force_path = true!

:ack: on the docs here, I need to start editing ./doc/man/task-sync.5

if (encryption_secret == "") {
throw std::string("sync.encryption_secret is required");
}
Expand Down Expand Up @@ -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 != "") {
Expand Down
48 changes: 45 additions & 3 deletions src/taskchampion-cpp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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`.
Expand All @@ -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`.
Expand Down Expand Up @@ -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)?)
Expand All @@ -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)?)
Expand All @@ -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)?)
Expand Down
Loading