]> granicus.if.org Git - icinga2/commitdiff
Fix that "repository add" writes invalid "type" attribute
authorMichael Friedrich <michael.friedrich@netways.de>
Thu, 17 Dec 2015 09:20:41 +0000 (10:20 +0100)
committerMichael Friedrich <michael.friedrich@netways.de>
Thu, 17 Dec 2015 09:20:41 +0000 (10:20 +0100)
fixes #10867

lib/cli/repositoryutility.cpp

index bcbaf1070122efcee37e6eb948bdef0f827781db..9d548441de928417956082e11421f7419958011b 100644 (file)
@@ -233,12 +233,15 @@ bool RepositoryUtility::AddObject(const std::vector<String>& object_paths, const
        if (check_config) {
                try {
                        ConfigObject::Ptr object = static_pointer_cast<ConfigObject>(utype->Instantiate());
+                       /* temporarly set the object type for validation */
                        attrs->Set("type", utype->GetName());
                        Deserialize(object, attrs, false, FAConfig);
                        object->SetName(name);
 
                        RepositoryValidationUtils utils;
                        static_pointer_cast<ConfigObject>(object)->Validate(FAConfig, utils);
+
+                       attrs->Remove("type");
                } catch (const ValidationError& ex) {
                        Log(LogCritical, "config", DiagnosticInformation(ex));
                        return false;