Skip to content

Commit 0d04ff5

Browse files
authored
Merge pull request #20 from ingenerator/0.5-maint-gax-credentials
Use latest google/gax InsecureCredentialsWrapper instead of cloud-core
2 parents c14fd44 + fc82510 commit 0d04ff5

File tree

5 files changed

+69
-13
lines changed

5 files changed

+69
-13
lines changed

.github/workflows/test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,32 @@ jobs:
2323
dependencies: 'lowest'
2424
- php_version: '8.2'
2525
dependencies: 'lowest'
26+
env:
27+
php_extensions: grpc, protobuf
2628
steps:
29+
30+
- name: Setup extension cache
31+
id: extension_cache
32+
uses: shivammathur/cache-extensions@v1
33+
with:
34+
php-version: ${{ matrix.php_version }}
35+
extensions: ${{ env.php_extensions }}
36+
# NB the extension cache has an indefinite expiry, manually bump this key to trigger extension updates
37+
key: extensions-cache-v1
38+
39+
- name: Cache extensions
40+
uses: actions/cache@v3
41+
with:
42+
path: ${{ steps.extension_cache.outputs.dir }}
43+
key: ${{ steps.extension_cache.outputs.key }}
44+
restore-keys: ${{ steps.extension_cache.outputs.key }}
45+
2746
- name: Setup PHP
2847
uses: shivammathur/setup-php@v2
2948
with:
3049
php-version: ${{ matrix.php_version }}
3150
tools: composer:v2
51+
extensions: ${{ env.php_extensions }}
3252

3353
- name: Checkout
3454
uses: actions/checkout@v2

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
## Unreleased
22

3+
## v0.5.6 (2024-02-28)
4+
5+
* Require google/gax:^1.29.1 for the new InsecureCredentialsWrapper class for emulator connections.
6+
Google have moved this class to google/gax (from google/cloud-core) as part of the followup to the
7+
gax release that broke the cloud-core version. We can now require that directly, because
8+
google/cloud-tasks already requires it. This also means that consuming projects no longer need to
9+
explicitly require google/cloud-core just to use a Cloud Tasks emulator.
10+
311
## v0.5.5 (2024-02-14)
412

513
* Support psr/http-message:^2.0

composer.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,18 @@
1414
"php": "~8.1.0 || ~8.2.0",
1515
"ext-bcmath": "*",
1616
"google/cloud-tasks": "^1.8",
17+
"google/gax": "^1.29.1",
1718
"google/protobuf": "^3.22.0",
1819
"ingenerator/oidc-token-verifier": "^0.3 || ^1.0",
1920
"ingenerator/php-utils": "^1.13 || ^2.0",
2021
"psr/http-message": "^1.0 || ^2.0"
2122
},
2223
"require-dev": {
24+
"ext-grpc": "*",
2325
"fig/log-test": "^1.1",
24-
"google/cloud-core": "^1.14.4",
25-
"guzzlehttp/psr7": "^1.7",
26+
"guzzlehttp/psr7": "^2.6",
2627
"phpunit/phpunit": "^9.5.5"
2728
},
28-
"conflict": {
29-
"google/gax": "<1.16"
30-
},
31-
"suggest": {
32-
"google/cloud-core": "You need google/cloud-core >1.44.4 to use a cloud tasks emulator with insecure credentials"
33-
},
3429
"repositories": [
3530
{"type": "composer", "url": "https://php-packages.ingenerator.com"}
3631
],

src/Client/CloudTasksClientFactory.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Ingenerator\CloudTasksWrapper\Client;
55

66

7-
use Google\Cloud\Core\InsecureCredentialsWrapper;
7+
use Google\ApiCore\InsecureCredentialsWrapper;
88
use Google\Cloud\Tasks\V2\CloudTasksClient;
99
use Grpc\Channel;
1010
use Grpc\ChannelCredentials;
@@ -21,10 +21,6 @@ public static function makeClient(CacheItemPoolInterface $auth_cache, array $con
2121
];
2222

2323
if ($config['use_emulator']) {
24-
if (!class_exists(InsecureCredentialsWrapper::class)) {
25-
throw new RuntimeException(
26-
'You need google/cloud-core >1.44.4 to use a cloud tasks emulator with insecure credentials');
27-
}
2824
$options = array_merge(
2925
$base_options,
3026
[
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace test\integration;
4+
5+
use Google\ApiCore\CredentialsWrapper;
6+
use Google\Cloud\Tasks\V2\CloudTasksClient;
7+
use Ingenerator\CloudTasksWrapper\Client\CloudTasksClientFactory;
8+
use PHPUnit\Framework\TestCase;
9+
use Psr\Cache\CacheItemPoolInterface;
10+
11+
class CloudTasksClientFactoryTest extends TestCase
12+
{
13+
14+
public function test_it_can_create_client_when_called_with_emulator_configuration()
15+
{
16+
$cache = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
17+
$client = CloudTasksClientFactory::makeClient($cache, [
18+
'use_emulator' => true,
19+
'emulator_endpoint' => 'cloud_tasks_emulator:8123',
20+
'credentials' => null
21+
]);
22+
$this->assertInstanceOf(CloudTasksClient::class, $client);
23+
}
24+
25+
public function test_it_can_create_client_when_called_with_production_configuration()
26+
{
27+
$cache = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
28+
$client = CloudTasksClientFactory::makeClient($cache, [
29+
'use_emulator' => false,
30+
// NB that the emulator_endpoint is not relevant here, but it doesn't matter
31+
// if a project still provides it.
32+
'emulator_endpoint' => 'cloud_tasks_emulator:8123',
33+
'credentials' => $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(),
34+
]);
35+
$this->assertInstanceOf(CloudTasksClient::class, $client);
36+
}
37+
}

0 commit comments

Comments
 (0)