mirror of https://github.com/Icinga/icinga2.git
Refactor MacroResolver::OverrideMacros
This commit is contained in:
parent
be2701bc8a
commit
a33560548c
|
@ -643,9 +643,9 @@ Dictionary::Ptr ApiActions::ExecuteCommand(const ConfigObject::Ptr& object,
|
|||
/* Check if resolved_command exists and it is of type command_type */
|
||||
Dictionary::Ptr execMacros = new Dictionary();
|
||||
|
||||
MacroResolver::overrideMacros = execMacros;
|
||||
MacroResolver::OverrideMacros = execMacros;
|
||||
Defer o ([]() {
|
||||
MacroResolver::overrideMacros = nullptr;
|
||||
MacroResolver::OverrideMacros = nullptr;
|
||||
});
|
||||
|
||||
if (command_type == "CheckCommand") {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
thread_local Dictionary::Ptr MacroResolver::overrideMacros;
|
||||
thread_local Dictionary::Ptr MacroResolver::OverrideMacros;
|
||||
|
||||
Value MacroProcessor::ResolveMacros(const Value& str, const ResolverList& resolvers,
|
||||
const CheckResult::Ptr& cr, String *missingMacro,
|
||||
|
|
|
@ -21,7 +21,7 @@ class MacroResolver
|
|||
public:
|
||||
DECLARE_PTR_TYPEDEFS(MacroResolver);
|
||||
|
||||
static thread_local Dictionary::Ptr overrideMacros;
|
||||
static thread_local Dictionary::Ptr OverrideMacros;
|
||||
|
||||
virtual bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, Value *result) const = 0;
|
||||
};
|
||||
|
|
|
@ -29,8 +29,8 @@ void PluginCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
|
|||
tie(host, service) = GetHostService(checkable);
|
||||
|
||||
MacroProcessor::ResolverList resolvers;
|
||||
if (MacroResolver::overrideMacros)
|
||||
resolvers.emplace_back("override", MacroResolver::overrideMacros);
|
||||
if (MacroResolver::OverrideMacros)
|
||||
resolvers.emplace_back("override", MacroResolver::OverrideMacros);
|
||||
|
||||
if (service)
|
||||
resolvers.emplace_back("service", service);
|
||||
|
|
Loading…
Reference in New Issue