better leader support in extra

This commit is contained in:
Emmanuel Garette 2021-11-23 08:51:03 +01:00
parent e75965fad2
commit f9acc7d6f8
15 changed files with 59 additions and 59 deletions

View File

@ -448,7 +448,7 @@ class RougailBaseTemplate:
await suboption.option.name(),
await suboption.option.path(),
)
variables[leadership_name] = leader
variables[leadership_name] = RougailExtra({leader_name: leader})
else:
if is_service_namespace == 'root':
new_is_service_namespace = 'service_name'

View File

@ -118,7 +118,7 @@ def process(filename: str,
)
data = str(cheetah_template)
except NotFound as err: # pragma: no cover
varname = err.args[0][13:-1]
varname = err.args[0][13:].split(' ', 1)[0][:-1]
if filename:
msg = f"Error: unknown variable used in template {filename} to {destfilename}: {varname}"
else:

View File

@ -2,7 +2,7 @@
<rougail version="0.10">
<variables>
<family name="ejabberd">
<family name="description" description="description" leadership="True">
<family name="leadership" description="description" leadership="True">
<variable name="description" type="string" multi="True">
<value>test</value>
</variable>

View File

@ -7,13 +7,13 @@
"owner": "default",
"value": "non"
},
"extra.ejabberd.description.description": {
"extra.ejabberd.leadership.description": {
"owner": "default",
"value": [
"test"
]
},
"extra.ejabberd.description.mode": {
"extra.ejabberd.leadership.mode": {
"owner": [
"default"
],

View File

@ -1,10 +1,10 @@
{
"rougail.general.mode_conteneur_actif": "non",
"rougail.general.activer_ejabberd": "non",
"extra.ejabberd.description.description": [
"extra.ejabberd.leadership.description": [
{
"extra.ejabberd.description.description": "test",
"extra.ejabberd.description.mode": "pre"
"extra.ejabberd.leadership.description": "test",
"extra.ejabberd.leadership.mode": "pre"
}
],
"services.test.files.mailname.name": "/etc/mailname",

View File

@ -7,13 +7,13 @@
"owner": "default",
"value": "non"
},
"extra.ejabberd.description.description": {
"extra.ejabberd.leadership.description": {
"owner": "default",
"value": [
"test"
]
},
"extra.ejabberd.description.mode": {
"extra.ejabberd.leadership.mode": {
"owner": [
"default"
],

View File

@ -17,7 +17,7 @@ option_2 = OptionDescription(name="general", doc="général", children=[option_3
option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2])
option_8 = StrOption(name="description", doc="description", multi=True, default=['test'], properties=frozenset({"mandatory"}))
option_9 = StrOption(name="mode", doc="mode", multi=True, default_multi="pre", properties=frozenset({"mandatory", "normal"}))
option_7 = Leadership(name="description", doc="description", children=[option_8, option_9], properties=frozenset({"normal"}))
option_7 = Leadership(name="leadership", doc="description", children=[option_8, option_9], properties=frozenset({"normal"}))
option_6 = OptionDescription(name="ejabberd", doc="ejabberd", children=[option_7], properties=frozenset({"normal"}))
option_5 = OptionDescription(name="extra", doc="extra", children=[option_6])
option_14 = FilenameOption(name="name", doc="name", default="/etc/mailname")

View File

@ -1,11 +1,11 @@
%if 'test' in %%extra.ejabberd.description
%if 'test' in %%extra.ejabberd.leadership.description
contain test
%end if
%%len(%%extra.ejabberd.description)
%if 'a' in %%extra.ejabberd.description
%%len(%%extra.ejabberd.leadership.description)
%if 'a' in %%extra.ejabberd.leadership.description
contain a
%end if
%for %%description in %%extra.ejabberd.description
%for %%description in %%extra.ejabberd.leadership.description
leader: %%description
follower: %%description.mode
%if %%description <= %%description.mode
@ -31,5 +31,5 @@ diff
%set %%var = %%description.mode + %%description
%%var
%end for
leader2: %%extra.ejabberd.description[0]
follower2: %%extra.ejabberd.description[0].mode
leader2: %%extra.ejabberd.leadership.description[0]
follower2: %%extra.ejabberd.leadership.description[0].mode

View File

@ -1,11 +1,11 @@
{% if 'test' in extra.ejabberd.description -%}
{% if 'test' in extra.ejabberd.leadership.description -%}
contain test
{% endif -%}
{{ extra.ejabberd.description|length }}
{% if 'a' in extra.ejabberd.description -%}
{{ extra.ejabberd.leadership.description|length }}
{% if 'a' in extra.ejabberd.leadership.description -%}
contain a
{% endif -%}
{% for description in extra.ejabberd.description -%}
{% for description in extra.ejabberd.leadership.description -%}
leader: {{ description }}
follower: {{ description.mode }}
{% if description <= description.mode -%}
@ -29,5 +29,5 @@ diff
{{ description + description.mode }}
{{ description.mode + description }}
{% endfor -%}
leader2: {{ extra.ejabberd.description[0] }}
follower2: {{ extra.ejabberd.description[0].mode }}
leader2: {{ extra.ejabberd.leadership.description[0] }}
follower2: {{ extra.ejabberd.leadership.description[0].mode }}

View File

@ -1,11 +1,11 @@
%if 'test' in %%extra.ejabberd.new_name
%if 'test' in %%extra.ejabberd.new_name.description
contain test
%end if
%%len(%%extra.ejabberd.new_name)
%if 'a' in %%extra.ejabberd.new_name
%%len(%%extra.ejabberd.new_name.description)
%if 'a' in %%extra.ejabberd.new_name.description
contain a
%end if
%for %%description in %%extra.ejabberd.new_name
%for %%description in %%extra.ejabberd.new_name.description
leader: %%description
follower: %%description.mode
%if %%description <= %%description.mode
@ -31,5 +31,5 @@ diff
%set %%var = %%description.mode + %%description
%%var
%end for
leader2: %%extra.ejabberd.new_name[0].description
follower2: %%extra.ejabberd.new_name[0].mode
leader2: %%extra.ejabberd.new_name.description[0].description
follower2: %%extra.ejabberd.new_name.description[0].mode

View File

@ -1,11 +1,11 @@
{% if 'test' in extra.ejabberd.new_name -%}
{% if 'test' in extra.ejabberd.new_name.description -%}
contain test
{% endif -%}
{{ extra.ejabberd.new_name |length }}
{% if 'a' in extra.ejabberd.new_name -%}
{{ extra.ejabberd.new_name.description |length }}
{% if 'a' in extra.ejabberd.new_name.description -%}
contain a
{% endif -%}
{% for description in extra.ejabberd.new_name -%}
{% for description in extra.ejabberd.new_name.description -%}
leader: {{ description }}
follower: {{ description.mode }}
{% if description <= description.mode -%}
@ -29,5 +29,5 @@ diff
{{ description + description.mode }}
{{ description.mode + description }}
{% endfor -%}
leader2: {{ extra.ejabberd.new_name[0].description }}
follower2: {{ extra.ejabberd.new_name[0].mode }}
leader2: {{ extra.ejabberd.new_name.description[0].description }}
follower2: {{ extra.ejabberd.new_name.description[0].mode }}

View File

@ -1,11 +1,11 @@
%if 'test' in %%extra['ejabberd']['new_name']
%if 'test' in %%extra['ejabberd']['new_name']['description']
contain test
%end if
%%len(%%extra['ejabberd']['new_name'])
%if 'a' in %%extra['ejabberd']['new_name']
%%len(%%extra['ejabberd']['new_name']['description'])
%if 'a' in %%extra['ejabberd']['new_name']['description']
contain a
%end if
%for %%description in %%extra['ejabberd']['new_name']
%for %%description in %%extra['ejabberd']['new_name']['description']
leader: %%description
follower: %%description['mode']
%if %%description <= %%description['mode']
@ -31,5 +31,5 @@ diff
%set %%var = %%description['mode'] + %%description
%%var
%end for
leader2: %%extra['ejabberd']['new_name'][0]['description']
follower2: %%extra['ejabberd']['new_name'][0]['mode']
leader2: %%extra['ejabberd']['new_name']['description'][0]
follower2: %%extra['ejabberd']['new_name']['description'][0]['mode']

View File

@ -1,11 +1,11 @@
{% if 'test' in extra.ejabberd.new_name -%}
{% if 'test' in extra.ejabberd.new_name.description -%}
contain test
{% endif -%}
{{ extra.ejabberd.new_name |length }}
{% if 'a' in extra.ejabberd.new_name -%}
{{ extra.ejabberd.new_name.description |length }}
{% if 'a' in extra.ejabberd.new_name.description -%}
contain a
{% endif -%}
{% for description in extra.ejabberd.new_name -%}
{% for description in extra.ejabberd.new_name.description -%}
leader: {{ description }}
follower: {{ description.mode }}
{% if description <= description.mode -%}
@ -29,5 +29,5 @@ diff
{{ description + description.mode }}
{{ description.mode + description }}
{% endfor -%}
leader2: {{ extra.ejabberd.new_name[0].description }}
follower2: {{ extra.ejabberd.new_name[0].mode }}
leader2: {{ extra.ejabberd.new_name.description[0] }}
follower2: {{ extra.ejabberd.new_name.description[0].mode }}

View File

@ -1,11 +1,11 @@
%if 'test' in %%extra.ejabberd.description
%if 'test' in %%extra.ejabberd.description.description
contain test
%end if
%%len(%%extra.ejabberd.description)
%if 'a' in %%extra.ejabberd.description
%%len(%%extra.ejabberd.description.description)
%if 'a' in %%extra.ejabberd.description.description
contain a
%end if
%for %%description in %%extra.ejabberd.description
%for %%description in %%extra.ejabberd.description.description
leader: %%description
follower: %%description.mode
%if %%description <= %%description.mode
@ -31,5 +31,5 @@ diff
%set %%var = %%description.mode + %%description
%%var
%end for
leader2: %%extra.ejabberd.description[0]
follower2: %%extra.ejabberd.description[0].mode
leader2: %%extra.ejabberd.description.description[0]
follower2: %%extra.ejabberd.description.description[0].mode

View File

@ -1,11 +1,11 @@
{% if 'test' in extra.ejabberd.description -%}
{% if 'test' in extra.ejabberd.description.description -%}
contain test
{% endif -%}
{{ extra.ejabberd.description|length }}
{% if 'a' in extra.ejabberd.description -%}
{{ extra.ejabberd.description.description|length }}
{% if 'a' in extra.ejabberd.description.description -%}
contain a
{% endif -%}
{% for description in extra.ejabberd.description -%}
{% for description in extra.ejabberd.description.description -%}
leader: {{ description }}
follower: {{ description.mode }}
{% if description <= description.mode -%}
@ -29,5 +29,5 @@ diff
{{ description + description.mode }}
{{ description.mode + description }}
{% endfor -%}
leader2: {{ extra.ejabberd.description[0] }}
follower2: {{ extra.ejabberd.description[0].mode }}
leader2: {{ extra.ejabberd.description.description[0] }}
follower2: {{ extra.ejabberd.description.description[0].mode }}