-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support specifying GCP account credentials as a config option. #4855
Changes from 6 commits
a84dcf7
32fc842
2b5876d
2b403ca
bcd5339
8f09cb1
ec33fe3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,11 @@ Status GCS::init(const Config& config, ThreadPool* const thread_pool) { | |
} | ||
project_id_ = config.get("vfs.gcs.project_id", &found); | ||
assert(found); | ||
service_account_key_ = config.get("vfs.gcs.service_account_key", &found); | ||
assert(found); | ||
workload_identity_configuration_ = | ||
config.get("vfs.gcs.workload_identity_configuration", &found); | ||
assert(found); | ||
impersonate_service_account_ = | ||
config.get("vfs.gcs.impersonate_service_account", &found); | ||
assert(found); | ||
|
@@ -187,7 +192,18 @@ static shared_ptr<google::cloud::Credentials> apply_impersonation( | |
std::shared_ptr<google::cloud::Credentials> GCS::make_credentials( | ||
const google::cloud::Options& options) const { | ||
shared_ptr<google::cloud::Credentials> creds = nullptr; | ||
if (!endpoint_.empty() || getenv("CLOUD_STORAGE_EMULATOR_ENDPOINT")) { | ||
if (!service_account_key_.empty()) { | ||
if (!workload_identity_configuration_.empty()) { | ||
LOG_WARN( | ||
"Both GCS service account credentials and external account " | ||
"credentials were specified; picking the former"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. another string to update with the new terminology (maybe the exact config key name?). I also might phrase this as something like "service account key set; ignoring workload identity configuration" to make it a little clearer (at least in my opinion; you are of course free to leave it as-is). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, thanks! |
||
} | ||
creds = google::cloud::MakeServiceAccountCredentials( | ||
service_account_key_, options); | ||
} else if (!workload_identity_configuration_.empty()) { | ||
creds = google::cloud::MakeExternalAccountCredentials( | ||
workload_identity_configuration_, options); | ||
} else if (!endpoint_.empty() || getenv("CLOUD_STORAGE_EMULATOR_ENDPOINT")) { | ||
creds = google::cloud::MakeInsecureCredentials(); | ||
} else { | ||
creds = google::cloud::MakeGoogleDefaultCredentials(options); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
credentials
toconfiguration
here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks!