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
  • Loading branch information
araujorm committed Feb 3, 2023
1 parent d905318 commit ab6d96c
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 @@ -540,6 +540,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 ab6d96c

Please sign in to comment.