Skip to content

Commit

Permalink
add support for gcp application default auth on windows in object sto…
Browse files Browse the repository at this point in the history
…re (#5473)

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

* syntax err

* clippy

---------

Co-authored-by: Itay Azolay <[email protected]>
  • Loading branch information
Itayazolay and itay-jether authored Mar 6, 2024
1 parent 1553267 commit 8caec3b
Showing 1 changed file with 8 additions and 2 deletions.
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

0 comments on commit 8caec3b

Please sign in to comment.