Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from DockerPhpClient/test/tar-archive
add Image Manager
- Loading branch information
Showing
11 changed files
with
252 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php /** @noinspection PhpMissingFieldTypeInspection */ | ||
|
||
namespace Docker\Client\Context; | ||
|
||
class ContextFactory | ||
{ | ||
/** | ||
* @var class-string<Archive> $archiveClass | ||
*/ | ||
private $archiveClass; | ||
|
||
/** | ||
* ImageContextFactory constructor. | ||
* @param class-string<Archive> $archiveClass | ||
*/ | ||
public function __construct($archiveClass) | ||
{ | ||
$this->archiveClass = $archiveClass; | ||
} | ||
|
||
public function createImageContext(string $contextDirectory): ImageContext | ||
{ | ||
return new ImageContext($contextDirectory, new $this->archiveClass()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
|
||
namespace Docker\Client\Endpoint; | ||
|
||
use Docker\OpenAPI\Endpoint\ImageBuild as BaseEndpoint; | ||
use Docker\OpenAPI\Model\BuildInfo; | ||
|
||
class ImageBuild extends BaseEndpoint | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
protected function transformResponseBody(string $body, int $status, \Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType) | ||
{ | ||
if (200 === $status) { | ||
$data = $this->logToJson($body); | ||
return $serializer->deserialize($data, BuildInfo::class . '[]', 'json'); | ||
} | ||
return parent::transformResponseBody($body, $status, $serializer, $contentType); | ||
} | ||
|
||
/** | ||
* @param string $body | ||
* @return string | ||
*/ | ||
protected function logToJson(string $body): string | ||
{ | ||
$data = explode("\n", $body); | ||
|
||
// remove empty line(s) | ||
$data = array_filter($data, static function ($line) { | ||
return null !== $line && !empty($line); | ||
}); | ||
|
||
// rebuild as json array | ||
$data = "[" . implode(",", $data) . "]"; | ||
return $data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.