diff --git a/Datastore/Sources/DatastoreClient.swift b/Datastore/Sources/DatastoreClient.swift index b4dba00..0e793b6 100644 --- a/Datastore/Sources/DatastoreClient.swift +++ b/Datastore/Sources/DatastoreClient.swift @@ -26,12 +26,14 @@ public final class GoogleCloudDatastoreClient { eventLoop: eventLoop) /// Set the projectId to use for this client. In order of priority: + /// - Environment Variable (GOOGLE_PROJECT_ID) /// - Environment Variable (PROJECT_ID) /// - Service Account's projectID /// - `GoogleCloudDatastoreConfigurations` `project` property (optionally configured). /// - `GoogleCloudCredentialsConfiguration's` `project` property (optionally configured). - guard let projectId = ProcessInfo.processInfo.environment["PROJECT_ID"] ?? + guard let projectId = ProcessInfo.processInfo.environment["GOOGLE_PROJECT_ID"] ?? + ProcessInfo.processInfo.environment["PROJECT_ID"] ?? (refreshableToken as? OAuthServiceAccount)?.credentials.projectId ?? config.project ?? credentials.project else { throw GoogleCloudDatastoreError.projectIdMissing diff --git a/Datastore/Sources/README.md b/Datastore/Sources/README.md index e7384b3..3af5633 100644 --- a/Datastore/Sources/README.md +++ b/Datastore/Sources/README.md @@ -33,6 +33,7 @@ let gcs = try GoogleCloudDatastoreClient(credentials: credentialsConfiguration, ``` The order of priority for which configured projectID the DatastoreClient will use is as follows: +1. `$GOOGLE_PROJECT_ID` environment variable. 1. `$PROJECT_ID` environment variable. 2. The Service Accounts projectID (Service account configured via the credentials path in the credentials configuration). 3. `GoogleCloudDatastoreConfiguration`'s `project` property. diff --git a/PubSub/Sources/PubSubClient.swift b/PubSub/Sources/PubSubClient.swift index 88021ce..a82d946 100644 --- a/PubSub/Sources/PubSubClient.swift +++ b/PubSub/Sources/PubSubClient.swift @@ -17,7 +17,8 @@ public final class GoogleCloudPubSubClient { withConfig: config, andClient: httpClient, eventLoop: eventLoop) - guard let projectId = ProcessInfo.processInfo.environment["PROJECT_ID"] ?? + guard let projectId = ProcessInfo.processInfo.environment["GOOGLE_PROJECT_ID"] ?? + ProcessInfo.processInfo.environment["PROJECT_ID"] ?? (refreshableToken as? OAuthServiceAccount)?.credentials.projectId ?? config.project ?? credentials.project else { throw GoogleCloudPubSubError.projectIdMissing diff --git a/README.md b/README.md index 4d70cea..011986a 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Now setup the configuration. Optionally, you can register an empty `GoogleCloudCredentialsConfiguration()` and configure the following environment variables: ```shell -export PROJECT_ID=myprojectid-12345 +export GOOGLE_PROJECT_ID=myprojectid-12345 export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/service-account.json ``` diff --git a/SecretManager/Sources/README.md b/SecretManager/Sources/README.md index 6ca015e..b439326 100644 --- a/SecretManager/Sources/README.md +++ b/SecretManager/Sources/README.md @@ -33,6 +33,7 @@ let smc = try GoogleCloudSecretManagerClient(credentials: credentialsConfigurati ``` The order of priority for which configured projectID the SecretManagerClient will use is as follows: +1. `$GOOGLE_PROJECT_ID` environment variable. 1. `$PROJECT_ID` environment variable. 2. The Service Accounts projectID (Service account configured via the credentials path in the credentials configuration). 3. `GoogleCloudSecretManagerConfiguration`'s `project` property. diff --git a/SecretManager/Sources/SecretManagerClient.swift b/SecretManager/Sources/SecretManagerClient.swift index dda298c..4411e99 100644 --- a/SecretManager/Sources/SecretManagerClient.swift +++ b/SecretManager/Sources/SecretManagerClient.swift @@ -26,12 +26,14 @@ public final class GoogleCloudSecretManagerClient { eventLoop: eventLoop) /// Set the projectId to use for this client. In order of priority: + /// - Environment Variable (GOOGLE_PROJECT_ID) /// - Environment Variable (PROJECT_ID) /// - Service Account's projectID /// - `GoogleCloudSecretManagerConfigurations` `project` property (optionally configured). /// - `GoogleCloudCredentialsConfiguration's` `project` property (optionally configured). - guard let projectId = ProcessInfo.processInfo.environment["PROJECT_ID"] ?? + guard let projectId = ProcessInfo.processInfo.environment["GOOGLE_PROJECT_ID"] ?? + ProcessInfo.processInfo.environment["PROJECT_ID"] ?? (refreshableToken as? OAuthServiceAccount)?.credentials.projectId ?? config.project ?? credentials.project else { throw GoogleCloudSecretManagerError.projectIdMissing diff --git a/Storage/Sources/README.md b/Storage/Sources/README.md index a46e619..3aca4db 100644 --- a/Storage/Sources/README.md +++ b/Storage/Sources/README.md @@ -33,6 +33,7 @@ let gcs = try GoogleCloudStorageClient(credentials: credentialsConfiguration, ``` The order of priority for which configured projectID the StorageClient will use is as follows: +1. `$GOOGLE_PROJECT_ID` environment variable. 1. `$PROJECT_ID` environment variable. 2. The Service Accounts projectID (Service account configured via the credentials path in the credentials configuration). 3. `GoogleCloudStorageConfiguration`'s `project` property. diff --git a/Storage/Sources/StorageClient.swift b/Storage/Sources/StorageClient.swift index b507e02..1da6366 100644 --- a/Storage/Sources/StorageClient.swift +++ b/Storage/Sources/StorageClient.swift @@ -36,12 +36,14 @@ public final class GoogleCloudStorageClient { eventLoop: eventLoop) /// Set the projectId to use for this client. In order of priority: + /// - Environment Variable (GOOGLE_PROJECT_ID) /// - Environment Variable (PROJECT_ID) /// - Service Account's projectID /// - `GoogleCloudStorageConfigurations` `project` property (optionally configured). /// - `GoogleCloudCredentialsConfiguration's` `project` property (optionally configured). - guard let projectId = ProcessInfo.processInfo.environment["PROJECT_ID"] ?? + guard let projectId = ProcessInfo.processInfo.environment["GOOGLE_PROJECT_ID"] ?? + ProcessInfo.processInfo.environment["PROJECT_ID"] ?? (refreshableToken as? OAuthServiceAccount)?.credentials.projectId ?? storageConfig.project ?? credentials.project else { throw GoogleCloudStorageError.projectIdMissing diff --git a/Translation/Sources/README.md b/Translation/Sources/README.md index ca72d8c..1ea8dfb 100644 --- a/Translation/Sources/README.md +++ b/Translation/Sources/README.md @@ -33,6 +33,7 @@ let gct = try GoogleCloudTranslationClient(credentials: credentialsConfiguration ``` The order of priority for which configured projectID the TranslationClient will use is as follows: +1. `$GOOGLE_PROJECT_ID` environment variable. 1. `$PROJECT_ID` environment variable. 2. The Service Accounts projectID (Service account configured via the credentials path in the credentials configuration). 3. `GoogleCloudTranslationConfiguration`'s `project` property. diff --git a/Translation/Sources/TranslationClient.swift b/Translation/Sources/TranslationClient.swift index f780824..378b6ca 100644 --- a/Translation/Sources/TranslationClient.swift +++ b/Translation/Sources/TranslationClient.swift @@ -26,12 +26,14 @@ public final class GoogleCloudTranslationClient { eventLoop: eventLoop) /// Set the projectId to use for this client. In order of priority: + /// - Environment Variable (GOOGLE_PROJECT_ID) /// - Environment Variable (PROJECT_ID) /// - Service Account's projectID /// - `GoogleCloudTranslationConfigurations` `project` property (optionally configured). /// - `GoogleCloudCredentialsConfiguration's` `project` property (optionally configured). - guard let projectId = ProcessInfo.processInfo.environment["PROJECT_ID"] ?? + guard let projectId = ProcessInfo.processInfo.environment["GOOGLE_PROJECT_ID"] ?? + ProcessInfo.processInfo.environment["PROJECT_ID"] ?? (refreshableToken as? OAuthServiceAccount)?.credentials.projectId ?? config.project ?? credentials.project else { throw GoogleCloudTranslationError.projectIdMissing