From 5dbc70abfa8a68724d687c5034da1c8249e14e6c Mon Sep 17 00:00:00 2001 From: Itay Azolay Date: Tue, 5 Mar 2024 18:57:00 +0200 Subject: [PATCH 1/3] add support for gcp application default auth on windows in object store --- 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..73f68f73f45f 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. From f3d2b45d8d31d63cc1376245a43148ffa3fca2ba Mon Sep 17 00:00:00 2001 From: Itay Azolay Date: Tue, 5 Mar 2024 22:25:23 +0200 Subject: [PATCH 2/3] syntax err --- object_store/src/gcp/credential.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/object_store/src/gcp/credential.rs b/object_store/src/gcp/credential.rs index 73f68f73f45f..6f3c5338b1cc 100644 --- a/object_store/src/gcp/credential.rs +++ b/object_store/src/gcp/credential.rs @@ -397,7 +397,7 @@ impl ApplicationDefaultCredentials { "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. From e614251dc18ada98a0378a449b857e824aa39bc8 Mon Sep 17 00:00:00 2001 From: Itay Azolay Date: Wed, 6 Mar 2024 08:59:36 +0200 Subject: [PATCH 3/3] clippy --- object_store/src/gcp/credential.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/object_store/src/gcp/credential.rs b/object_store/src/gcp/credential.rs index 6f3c5338b1cc..34cd6eeb6ea4 100644 --- a/object_store/src/gcp/credential.rs +++ b/object_store/src/gcp/credential.rs @@ -407,7 +407,7 @@ impl ApplicationDefaultCredentials { return read_credentials_file::(path).map(Some); } - let home_var = if cfg!(windows) {"APPDATA"} else {"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);