← 输入框|github.com|刷新
Skip to content

Commit a9115cf

Browse files
committed
feat: support Docker Engine API v1.57
Allow the docker-php-api 7.1.57 line, which Composer installs unless an application requires another line. Add it to the CI matrix and run it against Docker 29. API 1.57 declares JSON error responses for the logs and exec start endpoints, so the generated exceptions now deserialize the error body. Give the endpoint tests' serializer mock a return value, and compare thrown exceptions as well as return values.
1 parent 370d8d3 commit a9115cf

10 files changed

Lines changed: 33 additions & 17 deletions

File tree

‎.github/workflows/continuous-integration.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ jobs:
6161
strategy:
6262
fail-fast: false
6363
matrix:
64-
api-line: ["7.1.45", "7.1.46", "7.1.47", "7.1.48", "7.1.49", "7.1.50", "7.1.51", "7.1.52", "7.1.53", "7.1.54", "7.1.55", "7.1.56"]
64+
api-line: ["7.1.45", "7.1.46", "7.1.47", "7.1.48", "7.1.49", "7.1.50", "7.1.51", "7.1.52", "7.1.53", "7.1.54", "7.1.55", "7.1.56", "7.1.57"]
6565
# The runner's daemon is older than the newest lines, so those negotiate down.
6666
docker: [runner]
6767
include:
6868
# Run the newest line against a daemon that supports it without negotiation.
69-
- api-line: "7.1.56"
69+
- api-line: "7.1.57"
7070
docker: "29"
7171

7272
services:

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ maintenance of the original `docker-php/docker-php` repository to give you a
2828
better upgrade path. Development will continue here, and we will archive
2929
`beluga-php/docker-php` once the migration is complete.
3030

31-
Version 4.0 works with Docker Engine API v1.45 to v1.56. See
31+
Version 4.1 works with Docker Engine API v1.45 to v1.57. See
3232
[Upgrading to 4.0](#upgrading-to-40) below for how to migrate from existing
3333
releases.
3434

@@ -82,7 +82,7 @@ These guides cover callback streams, TTY output and raw response framing.
8282

8383
Each Docker Engine API version has its own `docker-php/docker-php-api` line with
8484
generated endpoints and models. The line uses the four-part version
85-
`Jane-major.Docker-major.Docker-minor.revision`: `7.1.56.0` means Docker API 1.56,
85+
`Jane-major.Docker-major.Docker-minor.revision`: `7.1.57.0` means Docker API 1.57,
8686
generated with Jane 7, revision 0. To use a specific version, require its line:
8787

8888
```bash

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "library",
66
"require": {
77
"php": ">=8.2",
8-
"docker-php/docker-php-api": ">=7.1.45.0 <7.1.57.0",
8+
"docker-php/docker-php-api": ">=7.1.45.0 <7.1.58.0",
99
"nyholm/psr7": "^1.8",
1010
"php-http/client-common": "^2.7",
1111
"php-http/discovery": "^1.19",

‎docs/api-versions.mdx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: "Choose a Docker Engine API version and how requests negotiate with
55

66
## Choose an API version
77

8-
Docker PHP 4.0 works with Docker Engine API v1.45 to v1.56. Each version has its
8+
Docker PHP 4.1 works with Docker Engine API v1.45 to v1.57. Each version has its
99
own `docker-php/docker-php-api` release line with generated endpoints and
1010
models. Without a direct API requirement, Composer installs the newest line.
1111

@@ -29,8 +29,8 @@ for the version you use.
2929
`docker-php/docker-php` follows semantic versioning.
3030

3131
`docker-php/docker-php-api` uses a four-part scheme:
32-
`Jane-major.Docker-major.Docker-minor.revision`. For example, `7.1.56.0` means
33-
Docker Engine API v1.56, generated with Jane 7, revision 0. Keep a direct API
32+
`Jane-major.Docker-major.Docker-minor.revision`. For example, `7.1.57.0` means
33+
Docker Engine API v1.57, generated with Jane 7, revision 0. Keep a direct API
3434
requirement within one line, as above. A constraint such as `^7.1.45.0` allows
3535
every newer Docker specification.
3636

@@ -83,5 +83,5 @@ from responses and ignored in requests.
8383

8484
Each line is generated from Docker's specification for that version with Jane
8585
7.14.4, without local patches. The API repository has one branch per line,
86-
such as [`7.1.56`](https://github.com/docker-php/docker-php-api/tree/7.1.56); see its
86+
such as [`7.1.57`](https://github.com/docker-php/docker-php-api/tree/7.1.57); see its
8787
[generation instructions](https://github.com/docker-php/docker-php-api#generation).

‎docs/guides/guzzle.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ expose an unauthenticated daemon to an untrusted network.
150150

151151
### Paths, timeouts and streaming
152152

153-
Use the daemon's root URL for `base_uri`, without a version such as `/v1.56`.
153+
Use the daemon's root URL for `base_uri`, without a version such as `/v1.57`.
154154
These Guzzle examples keep the generated server plugins enabled, so Docker PHP
155155
adds the installed API line's path. Guzzle clients do not negotiate, and
156156
`DOCKER_API_VERSION` only configures the bundled factory, so install an

‎docs/index.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ endpoint methods and models, connection handling, and decoded log and command
88
output streams.
99

1010
<Note>
11-
These docs cover the Docker PHP 4.0 client, which works with Docker Engine API
12-
v1.45 to v1.56. Upgrading from the original
11+
These docs cover the Docker PHP 4.1 client, which works with Docker Engine API
12+
v1.45 to v1.57. Upgrading from the original
1313
[docker-php 2.x](/migration#from-the-original-2-x-client) client,
1414
[beluga-php/docker-php](/migration#from-beluga) or
1515
[docker-php 3.x](/migration#from-3-x)? Start with the upgrade guide.

‎docs/migration.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ cannot upgrade yet can stay on `^3.3`, which keeps Docker Engine API v1.45.
8989

9090
### API version
9191

92-
4.0 works with API v1.45 to v1.56, and Composer installs the newest API line
92+
4.1 works with API v1.45 to v1.57, and Composer installs the newest API line
9393
unless you require one. Generated models and their methods differ between
9494
versions. To keep the 3.x models, require the v1.45 line:
9595

‎docs/reference/streams.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ $docker = Docker::create($httpClient);
8080
```
8181

8282
The generated server plugin supplies the installed API line's path, such as
83-
`/v1.56`, in this example. If your custom
83+
`/v1.57`, in this example. If your custom
8484
chain already supplies the versioned path, disable the server plugins with
8585
`Docker::create($httpClient, [], [], false)` to avoid configuring it twice.
8686

‎tests/Endpoint/ContainerLogsTest.php‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,15 @@ public function testNotFoundResponseUsesGeneratedException(): void
7171
throw new \LogicException('An error response must not inspect the container');
7272
});
7373

74+
// From API 1.57 the generated exception carries the deserialized error.
75+
$serializer = $this->createMock(SerializerInterface::class);
76+
$serializer->method('deserialize')->willReturnCallback(static fn (mixed $data, string $type): object => new $type());
77+
7478
$this->expectException(ContainerLogsNotFoundException::class);
7579

7680
$endpoint->parseResponse(
7781
new Response(404, ['Content-Type' => 'application/json'], '{"message":"No such container: missing"}'),
78-
$this->createMock(SerializerInterface::class)
82+
$serializer
7983
);
8084
}
8185
}

‎tests/Endpoint/ExecStartTest.php‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,23 @@ public static function nonStreamProvider(): iterable
9090
public function testNonStreamResponsesKeepGeneratedBehavior(int $status, string $contentType, string $body): void
9191
{
9292
$config = (new ExecIdStartPostBody())->setDetach(true);
93+
// From API 1.57 the generated endpoint deserializes JSON error bodies.
9394
$serializer = $this->createMock(SerializerInterface::class);
95+
$serializer->method('deserialize')->willReturnCallback(static fn (mixed $data, string $type): object => new $type());
9496
$headers = '' === $contentType ? [] : ['Content-Type' => $contentType];
95-
$expected = (new RawExecStart('test', $config))->parseResponse(new Response($status, $headers, $body), $serializer);
97+
$expected = self::outcome(static fn () => (new RawExecStart('test', $config))->parseResponse(new Response($status, $headers, $body), $serializer));
9698

97-
self::assertSame($expected, (new ExecStart('test', $config))->parseResponse(new Response($status, $headers, $body), $serializer));
99+
self::assertSame($expected, self::outcome(static fn () => (new ExecStart('test', $config))->parseResponse(new Response($status, $headers, $body), $serializer)));
100+
}
101+
102+
/** @return array{string, mixed} the return value, or the class of the exception thrown */
103+
private static function outcome(callable $parse): array
104+
{
105+
try {
106+
return ['return', $parse()];
107+
} catch (\Throwable $exception) {
108+
return ['throw', $exception::class];
109+
}
98110
}
99111

100112
public function testRawEndpointPreservesFrameHeaders(): void

0 commit comments

Comments
 (0)