fix: Versions correctly merged and checked

Closes #28
This commit is contained in:
jubianchi 2018-01-20 09:16:06 +01:00
parent add1fa32c0
commit fb1d7655f1
No known key found for this signature in database
GPG key ID: 5D9C896D2AA9E390
2 changed files with 16 additions and 0 deletions

View file

@ -50,11 +50,18 @@ $application->register('render')
} }
$configuration = readConfiguration($inputFile); $configuration = readConfiguration($inputFile);
$configurationVersion = (string) ($configuration['version'] ?? 1);
if (!$input->getOption('ignore-override') && file_exists($overrideFile)) { if (!$input->getOption('ignore-override') && file_exists($overrideFile)) {
$override = readConfiguration($overrideFile); $override = readConfiguration($overrideFile);
$overrideVersion = (string) ($override['version'] ?? 1);
if ($configurationVersion !== $overrideVersion) {
throw new Console\Exception\LogicException('Version mismatch: file ' . $inputFile . ' specifies version ' . $configurationVersion . ' but file ' . $overrideFile . ' uses version ' . $overrideVersion);
}
$configuration = array_merge_recursive($configuration, $override); $configuration = array_merge_recursive($configuration, $override);
$configuration['version'] = $configurationVersion;
} }
$services = fetchServices($configuration); $services = fetchServices($configuration);

View file

@ -28,6 +28,15 @@ function readConfiguration(string $path) : array
} }
} }
function validateVersion(array $configuration) : array
{
if (isset($configuration['version']) === false) {
return true;
}
}
/** /**
* @public * @public
* *