Skip to content

Commit

Permalink
Fix service inheritance with overrides on multiple nested levels
Browse files Browse the repository at this point in the history
Prevent host services from losing configuration from parent
imports when overriding service values.
  • Loading branch information
araujorm committed Nov 25, 2024
1 parent 4032d49 commit 204a61f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 2 additions & 3 deletions library/Director/CustomVariable/CustomVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,9 @@ public function toLegacyConfigString()
protected function renderSingleVar($key, $var, $renderExpressions = false)
{
if ($key === $this->overrideKeyName) {
return c::renderKeyOperatorValue(
return c::renderKeyValue(
$this->renderKeyName($key),
'+=',
$var->toConfigStringPrefetchable($renderExpressions)
'directorMergeOverrideConfig('.$this->renderKeyName($key) . ', ' . $var->toConfigStringPrefetchable($renderExpressions).')'
);
} else {
return c::renderKeyValue(
Expand Down
14 changes: 14 additions & 0 deletions library/Director/IcingaConfig/IcingaConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,20 @@ protected function renderHostOverridableVars()
)
}
}
globals.directorMergeOverrideConfig = function(existing,overrides) {
if (existing) {
for (service => conf in overrides) {
if (existing[service]) {
existing[service] += conf
} else {
existing[service] = conf
}
}
return existing
} else {
return overrides
}
}
template Service DirectorOverrideTemplate {
/**
Expand Down

0 comments on commit 204a61f

Please sign in to comment.