Skip to content

Commit

Permalink
Use GOOGLE_APPLICATION_CREDENTIALS and GCLOUD_PROJECT vars in RemoteG…
Browse files Browse the repository at this point in the history
…csHelper
  • Loading branch information
mziccard committed Nov 9, 2015
1 parent 2de9135 commit e90f19a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions utilities/integration_test_env.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e90f19a

Please sign in to comment.