Use GOOGLE_APPLICATION_CREDENTIALS instead of SERVICE_ACCOUNT_KEY_PATH The GOOGLE_APPLICATION_CREDENTIALS is a standard env variable name [1] so we better stick to the standard and not invent new names for the same purpose. [1] https://cloud.google.com/docs/authentication/application-default-credentials#GAC Change-Id: I00f495b8b9f2cf275088cb11fc99660fe54fa71a
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md index a816e2b..228f5b3 100644 --- a/src/main/resources/Documentation/build.md +++ b/src/main/resources/Documentation/build.md
@@ -41,11 +41,11 @@ In this case we have to provide an GCP service account key and the instance name under which the test refdb will be created. This is done by passing two -environment variables `SERVICE_ACCOUNT_KEY_PATH` and `SPANNER_INSTANCE`: +environment variables `GOOGLE_APPLICATION_CREDENTIALS` and `SPANNER_INSTANCE`: ``` bazelisk test \ - --test_env='SERVICE_ACCOUNT_KEY_PATH=/path/to/the/key.json' \ + --test_env='GOOGLE_APPLICATION_CREDENTIALS=/path/to/the/key.json' \ --test_env='SPANNER_INSTANCE=test-instance' \ --test_tag_filters=@PLUGIN@ //... ``` @@ -55,7 +55,7 @@ ``` bazelisk test \ - --test_env='SERVICE_ACCOUNT_KEY_PATH=/path/to/the/key.json' \ + --test_env='GOOGLE_APPLICATION_CREDENTIALS=/path/to/the/key.json' \ --test_env='SPANNER_INSTANCE=test-instance' \ //plugins/@PLUGIN@/... ``` @@ -66,7 +66,7 @@ the tests. A container running spanner will be created automatically by the tests. -The absence of the `SERVICE_ACCOUNT_KEY_PATH` env variable means that the tests +The absence of the `GOOGLE_APPLICATION_CREDENTIALS` env variable means that the tests will create local spanner emulator. ```
diff --git a/src/test/java/com/googlesource/gerrit/plugins/spannerrefdb/RealSpannerRefDb.java b/src/test/java/com/googlesource/gerrit/plugins/spannerrefdb/RealSpannerRefDb.java index 6635ac6..c1693f9 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/spannerrefdb/RealSpannerRefDb.java +++ b/src/test/java/com/googlesource/gerrit/plugins/spannerrefdb/RealSpannerRefDb.java
@@ -37,7 +37,7 @@ public static RealSpannerRefDb create() { if (INSTANCE == null) { - String keyPath = System.getenv("SERVICE_ACCOUNT_KEY_PATH"); + String keyPath = System.getenv("GOOGLE_APPLICATION_CREDENTIALS"); String instance = System.getenv("SPANNER_INSTANCE"); INSTANCE = new RealSpannerRefDb(keyPath, instance); }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/spannerrefdb/SpannerTestSystem.java b/src/test/java/com/googlesource/gerrit/plugins/spannerrefdb/SpannerTestSystem.java index aff7407..5b2d6e6 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/spannerrefdb/SpannerTestSystem.java +++ b/src/test/java/com/googlesource/gerrit/plugins/spannerrefdb/SpannerTestSystem.java
@@ -22,7 +22,7 @@ public static SpannerTestSystem create() throws Exception { SpannerTestSystem testSystem; - if (System.getenv("SERVICE_ACCOUNT_KEY_PATH") == null) { + if (System.getenv("GOOGLE_APPLICATION_CREDENTIALS") == null) { testSystem = new EmulatedSpannerRefDb(); } else { testSystem = RealSpannerRefDb.create();