Refactor MacroResolver::OverrideMacros

This commit is contained in:
Mattia Codato 2020-07-03 15:53:51 +02:00
parent be2701bc8a
commit a33560548c
4 changed files with 6 additions and 6 deletions

View File

@ -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") {

View File

@ -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,

View File

@ -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;
};

View File

@ -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);