Skip to content

Commit

Permalink
Merge pull request #10 from FrozenDonkey/master
Browse files Browse the repository at this point in the history
Adding Support for Credentials via env()
  • Loading branch information
schulzefelix committed Aug 12, 2020
2 parents 4dd7c3f + 3693fb2 commit f40b7fb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ return [
*/

'application_credentials' => env('GOOGLE_CLOUD_APPLICATION_CREDENTIALS'),


/*
| OPTIONAL:
| Use keyFile to use a json config from the current environment.
| For example secrets in laravel vapor
|
| https://docs.vapor.build/1.0/projects/environments.html#secrets
*/
//'keyFile' => json_decode(trim(env('GOOGLE_CLOUD_APPLICATION_CREDENTIALS')), true),

/*
|--------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/BigQueryClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public static function createForConfig(array $bigQueryConfig): BigQueryClient
$clientConfig = array_merge([
'projectId' => $bigQueryConfig['project_id'],
'keyFilePath' => $bigQueryConfig['application_credentials'],
'keyFile' => Arr::get($bigQueryConfig, 'keyFile', null),
'authCache' => self::configureCache($bigQueryConfig['auth_cache_store']),
], Arr::get($bigQueryConfig, 'client_options', []));

Expand Down
2 changes: 1 addition & 1 deletion src/BigQueryServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function register()

protected function guardAgainstInvalidConfiguration(array $bigQueryConfig = null)
{
if (! file_exists($bigQueryConfig['application_credentials'])) {
if (! file_exists($bigQueryConfig['application_credentials']) && ! array_key_exists('keyFile', $bigQueryConfig)) {
throw InvalidConfiguration::credentialsJsonDoesNotExist($bigQueryConfig['application_credentials']);
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/config/bigquery.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@

'application_credentials' => env('GOOGLE_CLOUD_APPLICATION_CREDENTIALS'),

/*
| OPTIONAL:
| Use keyFile to use a json config from the current environment.
| For example secrets in laravel vapor
|
| https://docs.vapor.build/1.0/projects/environments.html#secrets
*/
//'keyFile' => json_decode(trim(env('GOOGLE_CLOUD_APPLICATION_CREDENTIALS')), true),

/*
|--------------------------------------------------------------------------
| Project ID
Expand Down

0 comments on commit f40b7fb

Please sign in to comment.