Skip to content
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

add support for gcp application default auth on windows in object store #5473

Merged
merged 3 commits into from
Mar 6, 2024
Merged
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
10 changes: 8 additions & 2 deletions object_store/src/gcp/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,11 @@ pub enum ApplicationDefaultCredentials {
}

impl ApplicationDefaultCredentials {
const CREDENTIALS_PATH: &'static str = ".config/gcloud/application_default_credentials.json";
const CREDENTIALS_PATH: &'static str = if cfg!(windows) {
"gcloud/application_default_credentials.json"
} else {
".config/gcloud/application_default_credentials.json"
};

// Create a new application default credential in the following situations:
// 1. a file is passed in and the type matches.
Expand All @@ -402,7 +406,9 @@ impl ApplicationDefaultCredentials {
if let Some(path) = path {
return read_credentials_file::<Self>(path).map(Some);
}
if let Some(home) = env::var_os("HOME") {

let home_var = if cfg!(windows) { "APPDATA" } else { "HOME" };
if let Some(home) = env::var_os(home_var) {
let path = Path::new(&home).join(Self::CREDENTIALS_PATH);

// It's expected for this file to not exist unless it has been explicitly configured by the user.
Expand Down
Loading