From 601e5b7824fc8c569257b709a0cfb5620d1d5e3a Mon Sep 17 00:00:00 2001 From: Stephan Maximilian Huber Date: Tue, 28 May 2019 12:52:21 +0200 Subject: [PATCH] Fix bug with variants overriding existing configuration --- src/Configuration/BlueprintConfiguration.php | 8 +++++++- src/Configuration/ConfigurationService.php | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Configuration/BlueprintConfiguration.php b/src/Configuration/BlueprintConfiguration.php index fe91abfd..cf5715ba 100644 --- a/src/Configuration/BlueprintConfiguration.php +++ b/src/Configuration/BlueprintConfiguration.php @@ -86,7 +86,13 @@ public function expandVariants($blueprints) foreach ($blueprints as $data) { $template = $this->getTemplate($data['configName']); foreach ($data['variants'] as $variant) { - $this->configuration->addHost($template->expand($variant)); + $host = $template->expand($variant); + if (!$this->configuration->hasHostConfig($host['configName'])) { + $this->configuration->addHost($template->expand($variant)); + } + else { + $this->configuration->getLogger()->notice('There\'s an existing config with that name, skipping creating one from blueprint'); + } } } } diff --git a/src/Configuration/ConfigurationService.php b/src/Configuration/ConfigurationService.php index 17c8e6f2..ba31e2ba 100644 --- a/src/Configuration/ConfigurationService.php +++ b/src/Configuration/ConfigurationService.php @@ -710,4 +710,8 @@ protected function inheritFromBlueprint(string $config_name, $data): array return $data; } + + public function hasHostConfig($configName) { + return !empty($this->hosts[$configName]); + } }