Skip to content

Commit f2260b5

Browse files
committed
---
yaml --- r: 3769 b: refs/heads/pubsub-alpha c: 5fea95f h: refs/heads/master i: 3767: 0162a91
1 parent 7a755b5 commit f2260b5

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 36a62ef856d199f8efd09501b5ba65c422c01f23
33
refs/heads/travis: e21ee7b88a5edc3f3d8c71f90c3fc32abf7e8dd6
44
refs/heads/gh-pages: 7406918e071dd2c5677a638ae2a06e7592b6542c
5-
refs/heads/pubsub-alpha: 8df138b0aba5dbfa0a5b8dc07a1dc6541b4d2bac
5+
refs/heads/pubsub-alpha: 5fea95fcd9f7d98aa7ff682664686fa06321f07a
66
refs/heads/update-datastore: 47aae517c2cb33f1dccd909adaced73ec9d0f4df
77
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444
88
refs/tags/v0.0.10: 207ebd2a3472fddee69fe1298eb90429e3306efd

branches/pubsub-alpha/gcloud-java-core/src/main/java/com/google/gcloud/ServiceOptions.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.google.api.client.http.javanet.NetHttpTransport;
2828
import com.google.auth.http.HttpCredentialsAdapter;
2929
import com.google.common.collect.Iterables;
30+
import com.google.common.io.Files;
3031
import com.google.gcloud.spi.ServiceRpcFactory;
3132

3233
import java.io.BufferedReader;
@@ -42,6 +43,7 @@
4243
import java.lang.reflect.Method;
4344
import java.net.HttpURLConnection;
4445
import java.net.URL;
46+
import java.nio.charset.Charset;
4547
import java.util.Enumeration;
4648
import java.util.Locale;
4749
import java.util.Objects;
@@ -381,6 +383,18 @@ protected String defaultProject() {
381383
return projectId != null ? projectId : googleCloudProjectId();
382384
}
383385

386+
private static String activeGoogleCloudConfig(File configDir) {
387+
String activeGoogleCloudConfig = null;
388+
try {
389+
activeGoogleCloudConfig =
390+
Files.readFirstLine(new File(configDir, "active_config"), Charset.defaultCharset());
391+
} catch (IOException ex) {
392+
// ignore
393+
}
394+
// if reading active_config failed or the file is empty we try default
395+
return firstNonNull(activeGoogleCloudConfig, "default");
396+
}
397+
384398
protected static String googleCloudProjectId() {
385399
File configDir;
386400
if (System.getenv().containsKey("CLOUDSDK_CONFIG")) {
@@ -390,9 +404,10 @@ protected static String googleCloudProjectId() {
390404
} else {
391405
configDir = new File(System.getProperty("user.home"), ".config/gcloud");
392406
}
407+
String activeConfig = activeGoogleCloudConfig(configDir);
393408
FileReader fileReader = null;
394409
try {
395-
fileReader = new FileReader(new File(configDir, "configurations/config_default"));
410+
fileReader = new FileReader(new File(configDir, "configurations/config_" + activeConfig));
396411
} catch (FileNotFoundException newConfigFileNotFoundEx) {
397412
try {
398413
fileReader = new FileReader(new File(configDir, "properties"));

0 commit comments

Comments
 (0)