Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secondary environment variable name #49

Merged
merged 1 commit into from
Jul 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Datastore/Sources/DatastoreClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Datastore/Sources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion PubSub/Sources/PubSubClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 1 addition & 0 deletions SecretManager/Sources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion SecretManager/Sources/SecretManagerClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Storage/Sources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion Storage/Sources/StorageClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Translation/Sources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion Translation/Sources/TranslationClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down