mandatory_if_in only for variables

This commit is contained in:
Emmanuel Garette 2021-02-15 18:52:12 +01:00
parent 86ec629ce3
commit 6d571d8cac
5 changed files with 25 additions and 2 deletions

View File

@ -62,12 +62,15 @@ class TargetAnnotator:
f'is not allowed')
raise DictConsistencyError(msg, 8, obj.xmlfiles)
if target.type == 'family':
if obj.name not in ['disabled_if_in', 'disabled_if_not_in', "hidden_if_in", "hidden_if_not_in"]:
msg = _(f'target "{target.type}" not allow with "{obj.name}"')
raise DictConsistencyError(msg, 51, target.xmlfiles)
target.name = self.objectspace.paths.get_family(target.name,
obj.namespace,
)
elif target.type.endswith('list') and \
obj.name not in ['disabled_if_in', 'disabled_if_not_in']:
msg = _(f'target "{target.type}" not allow')
msg = _(f'target "{target.type}" not allow with "{obj.name}"')
raise DictConsistencyError(msg, 10, target.xmlfiles)
except DictConsistencyError as err:
if err.errno != 42:

View File

@ -132,7 +132,7 @@
<!ATTLIST param optional (True|False) "False">
<!ELEMENT target (#PCDATA)>
<!ATTLIST target type (family|variable|filelist|iplist|portlist) "variable">
<!ATTLIST target type (variable|family|filelist|iplist|portlist) "variable">
<!ATTLIST target optional (True|False) "False">
<!ELEMENT group (follower+)>

View File

@ -0,0 +1,20 @@
<?xml version='1.0' encoding='UTF-8'?>
<rougail>
<variables>
<family name="general">
<variable name="condition" type="boolean"/>
</family>
<family name="general2">
<variable name="my_variable"/>
</family>
</variables>
<constraints>
<condition name="mandatory_if_in" source="condition">
<param>oui</param>
<target type="family">general2</target>
</condition>
</constraints>
</rougail>
<!-- vim: ts=4 sw=4 expandtab
-->