From e90f19a36ce0a5c10d1d2a14d293ab50859d296f Mon Sep 17 00:00:00 2001 From: Marco Ziccardi Date: Mon, 9 Nov 2015 17:04:23 +0100 Subject: [PATCH] Use GOOGLE_APPLICATION_CREDENTIALS and GCLOUD_PROJECT vars in RemoteGcsHelper --- .../gcloud/storage/testing/RemoteGcsHelper.java | 15 +++++---------- utilities/integration_test_env.sh | 4 ++-- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java index b15768cffa98..1e7c1ca79f96 100644 --- a/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java +++ b/gcloud-java-storage/src/main/java/com/google/gcloud/storage/testing/RemoteGcsHelper.java @@ -45,8 +45,8 @@ public class RemoteGcsHelper { private static final Logger log = Logger.getLogger(RemoteGcsHelper.class.getName()); private static final String BUCKET_NAME_PREFIX = "gcloud-test-bucket-temp-"; - private static final String PROJECT_ID_ENV_VAR = "GCLOUD_TESTS_PROJECT_ID"; - private static final String PRIVATE_KEY_ENV_VAR = "GCLOUD_TESTS_KEY"; + private static final String PROJECT_ID_ENV_VAR = "GCLOUD_PROJECT"; + private static final String PRIVATE_KEY_ENV_VAR = "GOOGLE_APPLICATION_CREDENTIALS"; private final StorageOptions options; private RemoteGcsHelper(StorageOptions options) { @@ -145,22 +145,17 @@ public static RemoteGcsHelper create(String projectId, String keyPath) log.log(Level.WARNING, ex.getMessage()); } throw GcsHelperException.translate(ex); - } catch (IOException ex) { - if (log.isLoggable(Level.WARNING)) { - log.log(Level.WARNING, ex.getMessage()); - } - throw GcsHelperException.translate(ex); } } /** * Creates a {@code RemoteGcsHelper} object. Project id and path to JSON key are read from two - * environment variables: {@code GCLOUD_TESTS_PROJECT_ID} and {@code GCLOUD_TESTS_KEY}. + * environment variables: {@code GCLOUD_PROJECT} and {@code GOOGLE_APPLICATION_CREDENTIALS}. * * @return A {@code RemoteGcsHelper} object for the provided options. * @throws com.google.gcloud.storage.testing.RemoteGcsHelper.GcsHelperException if environment - * variables {@code GCLOUD_TESTS_PROJECT_ID} and {@code GCLOUD_TESTS_KEY} are not set or if - * the file pointed by {@code GCLOUD_TESTS_KEY} does not exist + * variables {@code GCLOUD_PROJECT} and {@code GOOGLE_APPLICATION_CREDENTIALS} are not set or + * if the file pointed by {@code GOOGLE_APPLICATION_CREDENTIALS} does not exist */ public static RemoteGcsHelper create() throws GcsHelperException { String projectId = System.getenv(PROJECT_ID_ENV_VAR); diff --git a/utilities/integration_test_env.sh b/utilities/integration_test_env.sh index f7aca1a8a623..a1bebe4dcb69 100755 --- a/utilities/integration_test_env.sh +++ b/utilities/integration_test_env.sh @@ -1,3 +1,3 @@ # Export test env variables -export GCLOUD_TESTS_PROJECT_ID="gcloud-devel" -export GCLOUD_TESTS_KEY=$TRAVIS_BUILD_DIR/signing-tools/gcloud-devel-travis.json +export GCLOUD_PROJECT="gcloud-devel" +export GOOGLE_APPLICATION_CREDENTIALS=$TRAVIS_BUILD_DIR/signing-tools/gcloud-devel-travis.json