Skip to content

Commit e90f19a

Browse files
committed
Use GOOGLE_APPLICATION_CREDENTIALS and GCLOUD_PROJECT vars in RemoteGcsHelper
1 parent 2de9135 commit e90f19a

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public class RemoteGcsHelper {
4545

4646
private static final Logger log = Logger.getLogger(RemoteGcsHelper.class.getName());
4747
private static final String BUCKET_NAME_PREFIX = "gcloud-test-bucket-temp-";
48-
private static final String PROJECT_ID_ENV_VAR = "GCLOUD_TESTS_PROJECT_ID";
49-
private static final String PRIVATE_KEY_ENV_VAR = "GCLOUD_TESTS_KEY";
48+
private static final String PROJECT_ID_ENV_VAR = "GCLOUD_PROJECT";
49+
private static final String PRIVATE_KEY_ENV_VAR = "GOOGLE_APPLICATION_CREDENTIALS";
5050
private final StorageOptions options;
5151

5252
private RemoteGcsHelper(StorageOptions options) {
@@ -145,22 +145,17 @@ public static RemoteGcsHelper create(String projectId, String keyPath)
145145
log.log(Level.WARNING, ex.getMessage());
146146
}
147147
throw GcsHelperException.translate(ex);
148-
} catch (IOException ex) {
149-
if (log.isLoggable(Level.WARNING)) {
150-
log.log(Level.WARNING, ex.getMessage());
151-
}
152-
throw GcsHelperException.translate(ex);
153148
}
154149
}
155150

156151
/**
157152
* Creates a {@code RemoteGcsHelper} object. Project id and path to JSON key are read from two
158-
* environment variables: {@code GCLOUD_TESTS_PROJECT_ID} and {@code GCLOUD_TESTS_KEY}.
153+
* environment variables: {@code GCLOUD_PROJECT} and {@code GOOGLE_APPLICATION_CREDENTIALS}.
159154
*
160155
* @return A {@code RemoteGcsHelper} object for the provided options.
161156
* @throws com.google.gcloud.storage.testing.RemoteGcsHelper.GcsHelperException if environment
162-
* variables {@code GCLOUD_TESTS_PROJECT_ID} and {@code GCLOUD_TESTS_KEY} are not set or if
163-
* the file pointed by {@code GCLOUD_TESTS_KEY} does not exist
157+
* variables {@code GCLOUD_PROJECT} and {@code GOOGLE_APPLICATION_CREDENTIALS} are not set or
158+
* if the file pointed by {@code GOOGLE_APPLICATION_CREDENTIALS} does not exist
164159
*/
165160
public static RemoteGcsHelper create() throws GcsHelperException {
166161
String projectId = System.getenv(PROJECT_ID_ENV_VAR);

utilities/integration_test_env.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Export test env variables
2-
export GCLOUD_TESTS_PROJECT_ID="gcloud-devel"
3-
export GCLOUD_TESTS_KEY=$TRAVIS_BUILD_DIR/signing-tools/gcloud-devel-travis.json
2+
export GCLOUD_PROJECT="gcloud-devel"
3+
export GOOGLE_APPLICATION_CREDENTIALS=$TRAVIS_BUILD_DIR/signing-tools/gcloud-devel-travis.json

0 commit comments

Comments
 (0)