Skip to content
This repository was archived by the owner on Oct 19, 2023. It is now read-only.

Commit a5a4dd5

Browse files
author
Takashi Matsuo
authored
Change the way we check the required version of the dependency (#428)
There are still some cases for false negative where the direct constrant is ok and other indirect dependency has a problem. Although the issue is not completely fixed, this logic change allows more legitimate cases which has been failing with the previous code. It will alleviate #426
1 parent f6de70a commit a5a4dd5

File tree

5 files changed

+38
-7
lines changed

5 files changed

+38
-7
lines changed

builder/gen-dockerfile/src/ValidateGoogleCloud.php

+10-5
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,19 @@ public static function doCheck($workspace)
9191
"no available matching version of $package"
9292
);
9393
}
94+
$found = false;
9495
foreach ($filtered as $version) {
95-
if (Comparator::lessThan($version, $minimumVersionMap[$package])) {
96-
throw new GoogleCloudVersionException(
97-
"stackdriver integration needs $package "
98-
. $minimumVersionMap[$package] . ' or higher'
99-
);
96+
if (Comparator::greaterThanOrEqualTo($version, $minimumVersionMap[$package])) {
97+
$found = true;
98+
break;
10099
}
101100
}
101+
if ($found === false) {
102+
throw new GoogleCloudVersionException(
103+
"stackdriver integration needs $package "
104+
. $minimumVersionMap[$package] . ' or higher'
105+
);
106+
}
102107
}
103108

104109
if (array_key_exists('google/cloud', $constraintsMap)) {

builder/gen-dockerfile/tests/GenFilesCommandTest.php

+16-1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,21 @@ public function dataProvider()
202202
"enable_stackdriver_integration.sh"
203203
]
204204
],
205+
[
206+
// stackdriver wildcard dep
207+
__DIR__ . '/test_data/stackdriver_wildcard',
208+
null,
209+
'',
210+
'/app/web',
211+
'added by the php runtime builder',
212+
'gcr.io/google-appengine/php72:latest',
213+
["COMPOSER_FLAGS='--no-dev --prefer-dist' \\\n",
214+
"FRONT_CONTROLLER_FILE='index.php' \\\n",
215+
"DETECTED_PHP_VERSION='7.2' \\\n",
216+
"IS_BATCH_DAEMON_RUNNING='true' \n",
217+
"enable_stackdriver_integration.sh"
218+
]
219+
],
205220
[
206221
// stackdriver individual packages
207222
__DIR__ . '/test_data/stackdriver_individual',
@@ -224,7 +239,7 @@ public function dataProvider()
224239
'',
225240
'/app/web',
226241
'added by the php runtime builder',
227-
'gcr.io/google-appengine/php71:latest',
242+
'gcr.io/google-appengine/php72:latest',
228243
[],
229244
'\\Google\\Cloud\\Runtimes\\Builder\\Exception\\GoogleCloudVersionException'
230245
],
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"require": {
3-
"google/cloud-logging": "^1.2.0",
3+
"google/cloud-logging": "<=1.2.0",
44
"google/cloud-error-reporting": "^0.4.1"
55
}
66
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
env: flex
2+
runtime: php
3+
4+
runtime_config:
5+
enable_stackdriver_integration: true
6+
document_root: web
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
"google/cloud": "*"
4+
}
5+
}

0 commit comments

Comments
 (0)