Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions src/Util/ComposeFileManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public function __construct(string $contents)
} else {
$this->manipulator = new YamlSourceManipulator($contents);
}

$this->checkComposeFileVersion();
}

public function getComposeData(): array
Expand Down Expand Up @@ -116,17 +114,4 @@ private function getBasicStructure(string $version = self::COMPOSE_FILE_VERSION)
'services' => [],
];
}

private function checkComposeFileVersion(): void
{
$data = $this->manipulator->getData();

if (empty($data['version'])) {
throw new RuntimeCommandException('compose.yaml file version is not set.');
}

if (2.0 > (float) $data['version']) {
throw new RuntimeCommandException(\sprintf('compose.yaml version %s is not supported. Please update your compose.yaml file to the latest version.', $data['version']));
}
}
}
22 changes: 0 additions & 22 deletions tests/Util/ComposeFileManipulatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,26 +140,4 @@ public function testAddVolume(): void

self::assertSame($expected, $manipulator->getComposeData());
}

public function testCheckComposeFileVersion(): void
{
new ComposeFileManipulator('version: \'2\'');

$this->expectException(RuntimeCommandException::class);
$this->expectExceptionMessage('compose.yaml version 1.9 is not supported. Please update your compose.yaml file to the latest version.');

new ComposeFileManipulator('version: \'1.9\'');
}

public function testCheckComposeFileVersionThrowsExceptionWithMissingVersion(): void
{
$composeFile = <<< 'EOT'
services:
[]
EOT;
$this->expectException(RuntimeCommandException::class);
$this->expectExceptionMessage('compose.yaml file version is not set.');

new ComposeFileManipulator($composeFile);
}
}
Loading