Skip to content
This repository was archived by the owner on Dec 3, 2023. It is now read-only.

Commit 2bb7d57

Browse files
authored
feat: Support get CREDENTIAL_ENV_NAME from properties (#782)
This closes #781. Signed-off-by: tison <[email protected]> Signed-off-by: tison <[email protected]>
1 parent ee64ef7 commit 2bb7d57

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,11 @@ protected ServiceOptions(
327327
quotaProjectId =
328328
builder.quotaProjectId != null
329329
? builder.quotaProjectId
330-
: getValueFromCredentialsFile(System.getenv(CREDENTIAL_ENV_NAME), "quota_project_id");
330+
: getValueFromCredentialsFile(getCredentialsPath(), "quota_project_id");
331+
}
332+
333+
private static String getCredentialsPath() {
334+
return System.getProperty(CREDENTIAL_ENV_NAME, System.getenv(CREDENTIAL_ENV_NAME));
331335
}
332336

333337
/**
@@ -511,7 +515,7 @@ static boolean headerContainsMetadataFlavor(HttpResponse response) {
511515
}
512516

513517
protected static String getServiceAccountProjectId() {
514-
return getValueFromCredentialsFile(System.getenv(CREDENTIAL_ENV_NAME), "project_id");
518+
return getValueFromCredentialsFile(getCredentialsPath(), "project_id");
515519
}
516520

517521
@InternalApi("Visible for testing")

0 commit comments

Comments
 (0)