mirror of https://github.com/Icinga/icinga2.git
Remove method validator.
This commit is contained in:
parent
22913c96bf
commit
df79e4c2dc
|
@ -31,9 +31,6 @@ type DynamicObject {
|
||||||
%attribute string "__type",
|
%attribute string "__type",
|
||||||
|
|
||||||
%attribute dictionary "methods" {
|
%attribute dictionary "methods" {
|
||||||
%validator "ValidateMethods",
|
|
||||||
|
|
||||||
%attribute string "*",
|
|
||||||
},
|
},
|
||||||
|
|
||||||
%attribute any "custom::*"
|
%attribute any "custom::*"
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
REGISTER_SCRIPTFUNCTION("ValidateMethods", &ConfigType::ValidateMethods);
|
|
||||||
|
|
||||||
ConfigType::ConfigType(const String& name, const DebugInfo& debuginfo)
|
ConfigType::ConfigType(const String& name, const DebugInfo& debuginfo)
|
||||||
: m_Name(name), m_RuleList(boost::make_shared<TypeRuleList>()), m_DebugInfo(debuginfo)
|
: m_Name(name), m_RuleList(boost::make_shared<TypeRuleList>()), m_DebugInfo(debuginfo)
|
||||||
{ }
|
{ }
|
||||||
|
@ -171,31 +169,3 @@ void ConfigType::ValidateDictionary(const Dictionary::Ptr& dictionary,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigType::ValidateMethods(const ScriptTask::Ptr& task,
|
|
||||||
const vector<Value>& arguments)
|
|
||||||
{
|
|
||||||
if (arguments.size() < 1)
|
|
||||||
BOOST_THROW_EXCEPTION(invalid_argument("Missing argument: Location must be specified."));
|
|
||||||
|
|
||||||
if (arguments.size() < 2)
|
|
||||||
BOOST_THROW_EXCEPTION(invalid_argument("Missing argument: Attribute dictionary must be specified."));
|
|
||||||
|
|
||||||
String location = arguments[0];
|
|
||||||
Dictionary::Ptr attrs = arguments[1];
|
|
||||||
|
|
||||||
String key;
|
|
||||||
Value value;
|
|
||||||
BOOST_FOREACH(tie(key, value), attrs) {
|
|
||||||
if (!value.IsScalar())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
String method = value;
|
|
||||||
|
|
||||||
if (!ScriptFunction::GetByName(method)) {
|
|
||||||
ConfigCompilerContext::GetContext()->AddError(false, "Validation failed for " +
|
|
||||||
location + ": Script function '" + method + "' not found.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task->FinishResult(Empty);
|
|
||||||
}
|
|
||||||
|
|
|
@ -46,9 +46,6 @@ public:
|
||||||
|
|
||||||
void ValidateItem(const ConfigItem::Ptr& object) const;
|
void ValidateItem(const ConfigItem::Ptr& object) const;
|
||||||
|
|
||||||
static void ValidateMethods(const ScriptTask::Ptr& task,
|
|
||||||
const vector<Value>& arguments);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_Name; /**< The type name. */
|
String m_Name; /**< The type name. */
|
||||||
String m_Parent; /**< The parent type. */
|
String m_Parent; /**< The parent type. */
|
||||||
|
|
Loading…
Reference in New Issue