Skip to content

Commit

Permalink
Removed include script in factory because the option does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
sebprt committed Oct 6, 2023
1 parent b23655a commit 9fdd99a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
20 changes: 0 additions & 20 deletions src/Adapter/Docker/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,6 @@ public function __invoke(array $configuration): Configurator\SatelliteBuilderInt
}
}

if (isset($configuration['docker']['include']) && is_iterable($configuration['docker']['include'])) {
foreach ($configuration['docker']['include'] as $path) {
if (is_dir($path)) {
$builder->withDirectory(new Packaging\Directory($path));
} else {
$builder->withFile(new Packaging\Asset\LocalFile($path));
}
}
}

if (isset($configuration['include'])) {
foreach ($configuration['include'] as $path) {
if (is_dir($path)) {
$builder->withDirectory(new Packaging\Directory($path));
} else {
$builder->withFile(new Packaging\Asset\LocalFile($path));
}
}
}

if (\array_key_exists('composer', $configuration)) {
if (\array_key_exists('from_local', $configuration['composer']) && true === $configuration['composer']['from_local']) {
if (file_exists('composer.lock')) {
Expand Down
16 changes: 16 additions & 0 deletions src/Adapter/Docker/Satellite.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public function dependsOn(string ...$dependencies): self
public function build(
LoggerInterface $logger,
): void {
$this->sortFiles();
$archive = new TarArchive($this->dockerfile, ...$this->files);

$iterator = function (iterable $tags) {
Expand Down Expand Up @@ -85,4 +86,19 @@ public function build(
throw new \RuntimeException('Process exited unexpectedly.');
}
}

private function sortFiles(): void
{
uksort($this->files, function ($a, $b) {
if (is_numeric($a) && is_numeric($b)) {
return $a - $b;
} elseif (is_numeric($a)) {
return -1;
} elseif (is_numeric($b)) {
return 1;
} else {
return strcmp($a, $b);
}
});
}
}

0 comments on commit 9fdd99a

Please sign in to comment.