Skip to content

Commit f9cca55

Browse files
committed
Add new env variable for project, change namespace for datastore example
1 parent fbb8f82 commit f9cca55

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Most `google-cloud` libraries require a project ID. There are multiple ways to
9595
```java
9696
Datastore datastore = DatastoreOptions.builder().projectId("PROJECT_ID").build().service();
9797
```
98-
* Specify the environment variable `GCLOUD_PROJECT` to be your desired project ID.
98+
* Specify the environment variable `GOOGLE_CLOUD_PROJECT` to be your desired project ID.
9999
* Set the project ID using the [Google Cloud SDK](https://cloud.google.com/sdk/?hl=en). To use the SDK, [download the SDK](https://cloud.google.com/sdk/?hl=en) if you haven't already, and set the project ID from the command line. For example:
100100

101101
```
@@ -105,7 +105,7 @@ Most `google-cloud` libraries require a project ID. There are multiple ways to
105105
`google-cloud` determines the project ID from the following sources in the listed order, stopping once it finds a value:
106106

107107
1. Project ID supplied when building the service options
108-
2. Project ID specified by the environment variable `GCLOUD_PROJECT`
108+
2. Project ID specified by the environment variable `GOOGLE_CLOUD_PROJECT`
109109
3. App Engine project ID
110110
4. Project ID specified in the JSON credentials file pointed by the `GOOGLE_APPLICATION_CREDENTIALS` environment variable
111111
5. Google Cloud SDK project ID

google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ public abstract class ServiceOptions<ServiceT extends Service<OptionsT>, Service
6464
OptionsT extends ServiceOptions<ServiceT, ServiceRpcT, OptionsT>> implements Serializable {
6565

6666
private static final String DEFAULT_HOST = "https://www.googleapis.com";
67-
private static final String PROJECT_ENV_NAME = "GCLOUD_PROJECT";
67+
private static final String LEGACY_PROJECT_ENV_NAME = "GCLOUD_PROJECT";
68+
private static final String PROJECT_ENV_NAME = "GOOGLE_CLOUD_PROJECT";
6869
private static final String MANIFEST_ARTIFACT_ID_KEY = "artifactId";
6970
private static final String MANIFEST_VERSION_KEY = "Implementation-Version";
70-
private static final String ARTIFACT_ID = "gcloud-java-core";
71+
private static final String ARTIFACT_ID = "google-cloud-core";
7172
private static final String LIBRARY_NAME = "gcloud-java";
7273
private static final String LIBRARY_VERSION = getLibraryVersion();
7374
private static final String APPLICATION_NAME =
@@ -261,6 +262,10 @@ protected String defaultHost() {
261262

262263
protected String defaultProject() {
263264
String projectId = System.getProperty(PROJECT_ENV_NAME, System.getenv(PROJECT_ENV_NAME));
265+
if (projectId == null) {
266+
projectId =
267+
System.getProperty(LEGACY_PROJECT_ENV_NAME, System.getenv(LEGACY_PROJECT_ENV_NAME));
268+
}
264269
if (projectId == null) {
265270
projectId = appEngineProjectId();
266271
}

google-cloud-examples/src/main/java/com/google/cloud/examples/datastore/DatastoreExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class DatastoreExample {
5353

5454
private static final String USER_KIND = "_DS_EXAMPLE_USER";
5555
private static final String COMMENT_KIND = "_DS_EXAMPLE_COMMENT";
56-
private static final String NAMESPACE = "gcloud_java_example";
56+
private static final String NAMESPACE = "google_cloud_example";
5757
private static final String DEFAULT_ACTION = "display";
5858
private static final Map<String, DatastoreAction> ACTIONS = new HashMap<>();
5959

0 commit comments

Comments
 (0)