forked from docker-php/docker-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageBuild.php
More file actions
44 lines (34 loc) · 1.37 KB
/
Copy pathImageBuild.php
File metadata and controls
44 lines (34 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
declare(strict_types=1);
namespace Docker\Endpoint;
use Docker\API\Endpoint\ImageBuild as BaseEndpoint;
use Docker\Stream\BuildStream;
use Docker\Stream\TarStream;
use Jane\OpenApiRuntime\Client\Client;
use Jane\OpenApiRuntime\Client\Exception\InvalidFetchModeException;
use Psr\Http\Message\ResponseInterface;
use Symfony\Component\Serializer\SerializerInterface;
class ImageBuild extends BaseEndpoint
{
public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, \Http\Message\StreamFactory $streamFactory = null): array
{
$body = $this->body;
if (\is_resource($body)) {
$body = new TarStream($body);
}
return [[], $body];
}
public function parsePSR7Response(ResponseInterface $response, SerializerInterface $serializer, string $fetchMode = Client::FETCH_OBJECT)
{
if (Client::FETCH_OBJECT === $fetchMode) {
if (200 === $response->getStatusCode()) {
return new BuildStream($response->getBody(), $serializer);
}
return $this->transformResponseBody((string) $response->getBody(), $response->getStatusCode(), $serializer);
}
if (Client::FETCH_RESPONSE === $fetchMode) {
return $response;
}
throw new InvalidFetchModeException(\sprintf('Fetch mode %s is not supported', $fetchMode));
}
}