Skip to content

Commit

Permalink
more concise way of checking AWS config
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Dec 17, 2024
1 parent ae7ee79 commit e12f1ba
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/commands/CmdSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,30 +100,21 @@ int CmdSync::execute(std::string& output) {
throw std::string("sync.encryption_secret is required");
}

int num_cred_methods = 0;
bool using_profile = false;
bool using_creds = false;
bool using_default = false;
if (aws_profile != "") {
using_profile = true;
num_cred_methods++;
}
if (aws_access_key_id != "" || aws_secret_access_key != "") {
using_creds = true;
num_cred_methods++;
}
if (aws_default_credentials != "") {
using_default = true;
num_cred_methods++;
}

if (!using_profile && !using_creds && !using_default) {
throw std::string("configuration for AWS credentials is required");
}

std::cout << "num_cred_method " << num_cred_methods << "\n";
if (num_cred_methods > 1) {
throw std::string("only one method of specifying AWS credentials is allowed");
if (using_profile + using_creds + using_default != 1) {
throw std::string("exactly one method of specifying AWS credentials is required");
}

if (verbose) {
Expand Down

0 comments on commit e12f1ba

Please sign in to comment.