Skip to content

Commit cbba45e

Browse files
authored
Merge pull request #173 from SimoTod/feature/emulator-mode
Feature - emulator mode
2 parents 269d99c + 8b3bdcc commit cbba45e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ before_script:
1414

1515
script:
1616
- mkdir -p build/logs
17-
- php vendor/bin/phpunit
17+
- php vendor/bin/phpunit
1818

1919
after_script:
2020
- php vendor/bin/coveralls -v

src/GDS/Gateway/RESTv1.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,18 @@ protected function httpClient()
9292
*/
9393
protected function initHttpClient()
9494
{
95-
9695
// Middleware
9796
$obj_stack = HandlerStack::create();
98-
$obj_stack->push(ApplicationDefaultCredentials::getMiddleware(['https://www.googleapis.com/auth/datastore']));
9997

10098
$str_base_url = self::DEFAULT_BASE_URL;
10199

102-
if (getenv("DATASTORE_EMULATOR_HOST") !== FALSE) {
103-
$str_base_url = getenv("DATASTORE_EMULATOR_HOST");
100+
$str_emulator_url = getenv("DATASTORE_EMULATOR_HOST");
101+
if (false !== $str_emulator_url) {
102+
$str_base_url = $str_emulator_url;
103+
} else {
104+
$obj_stack->push(
105+
ApplicationDefaultCredentials::getMiddleware(['https://www.googleapis.com/auth/datastore'])
106+
);
104107
}
105108

106109
// Create the HTTP client
@@ -508,4 +511,4 @@ private function actionUrl($str_action)
508511
return $this->getBaseUrl() . '/v1/projects/' . $this->str_dataset_id . ':' . $str_action;
509512
}
510513

511-
}
514+
}

0 commit comments

Comments
 (0)