Skip to content

Commit

Permalink
Merge pull request #329 from ajkannan/fix-config-loc
Browse files Browse the repository at this point in the history
Update location to look for gcloud SDK config file where we look for config file
  • Loading branch information
aozarov committed Nov 6, 2015
2 parents c615c91 + fa9348e commit 0e32a4b
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -387,8 +388,18 @@ protected static String googleCloudProjectId() {
} else {
configDir = new File(System.getProperty("user.home"), ".config/gcloud");
}
try (BufferedReader reader =
new BufferedReader(new FileReader(new File(configDir, "properties")))) {
FileReader fileReader;
try {
fileReader = new FileReader(new File(configDir, "configurations/config_default"));
} catch (FileNotFoundException newConfigFileNotFoundEx) {
try {
fileReader = new FileReader(new File(configDir, "properties"));
} catch (FileNotFoundException oldConfigFileNotFoundEx) {
// return null if we can't find config file
return null;
}
}
try (BufferedReader reader = new BufferedReader(fileReader)) {
String line;
String section = null;
Pattern projectPattern = Pattern.compile("^project\\s*=\\s*(.*)$");
Expand Down

0 comments on commit 0e32a4b

Please sign in to comment.