From 8caec3b28b819071421da8ef1938680ae6022c73 Mon Sep 17 00:00:00 2001 From: Itayazolay Date: Wed, 6 Mar 2024 21:07:29 +0200 Subject: [PATCH] add support for gcp application default auth on windows in object store (#5473) * add support for gcp application default auth on windows in object store * syntax err * clippy --------- Co-authored-by: Itay Azolay --- object_store/src/gcp/credential.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/object_store/src/gcp/credential.rs b/object_store/src/gcp/credential.rs index dc504da05723..34cd6eeb6ea4 100644 --- a/object_store/src/gcp/credential.rs +++ b/object_store/src/gcp/credential.rs @@ -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. @@ -402,7 +406,9 @@ impl ApplicationDefaultCredentials { if let Some(path) = path { return read_credentials_file::(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.