MacroProcessor::ResolveMacro(): treat quasi-CV-object IcingaApplication as real CV-object

As MacroProcessor checked just for CustomVarObject base class, but
IcingaApplication provided the vars attribute by itself, it had to also
resolve CV macros by itself. That logic diverged from MacroProcessor so that
macros inside IcingaApplication CVs weren't resolved. Until now.
This commit is contained in:
Alexander A. Klimov 2023-05-31 16:35:09 +02:00
parent 3276cc9412
commit a9c80ffb2e
2 changed files with 12 additions and 12 deletions

View File

@ -220,13 +220,6 @@ bool IcingaApplication::ResolveMacro(const String& macro, const CheckResult::Ptr
return true;
}
Dictionary::Ptr vars = GetVars();
if (vars && vars->Contains(macro)) {
*result = vars->Get(macro);
return true;
}
if (macro.Contains("num_services")) {
ServiceStatistics ss = CIB::CalculateServiceStats();

View File

@ -111,17 +111,24 @@ bool MacroProcessor::ResolveMacro(const String& macro, const ResolverList& resol
if (!resolver.ResolveShortMacros)
continue;
Dictionary::Ptr vars;
CustomVarObject::Ptr dobj = dynamic_pointer_cast<CustomVarObject>(resolver.Obj);
if (dobj) {
Dictionary::Ptr vars = dobj->GetVars();
vars = dobj->GetVars();
} else {
auto app (dynamic_pointer_cast<IcingaApplication>(resolver.Obj));
if (vars && vars->Contains(macro)) {
*result = vars->Get(macro);
*recursive_macro = true;
return true;
if (app) {
vars = app->GetVars();
}
}
if (vars && vars->Contains(macro)) {
*result = vars->Get(macro);
*recursive_macro = true;
return true;
}
}
auto *mresolver = dynamic_cast<MacroResolver *>(resolver.Obj.get());