feat: add inaccessible_read_write_modes and inaccessible_modes options
This commit is contained in:
parent
5ce01380bf
commit
0500688079
3 changed files with 56 additions and 1 deletions
|
|
@ -175,6 +175,29 @@ def load_user_datas(rougailconfig):
|
|||
rougail = Rougail(rougailconfig)
|
||||
layer_name = "_".join(layers[-1])
|
||||
subconfig = rougail.run(name=layer_name)
|
||||
try:
|
||||
read_write = set()
|
||||
read_only = set()
|
||||
if rougailconfig["cli.inaccessible_read_write_modes"]:
|
||||
read_write = set(rougailconfig["cli.inaccessible_read_write_modes"])
|
||||
if rougailconfig["cli.inaccessible_modes"]:
|
||||
read_only = set(rougailconfig["cli.inaccessible_modes"])
|
||||
read_write |= read_only
|
||||
if read_write:
|
||||
subconfig.property.setdefault(
|
||||
frozenset(subconfig.property.default("read_write", "append") | read_write), "read_write", "append"
|
||||
)
|
||||
subconfig.property.setdefault(
|
||||
frozenset(subconfig.property.default("read_only", "remove") | (read_write - read_only)), "read_only", "remove"
|
||||
)
|
||||
subconfig.property.read_write()
|
||||
if read_only:
|
||||
subconfig.property.setdefault(
|
||||
frozenset(subconfig.property.default("read_only", "append") | read_only), "read_only", "append"
|
||||
)
|
||||
subconfig.property.read_write()
|
||||
except:
|
||||
pass
|
||||
metaconfig = subconfig
|
||||
if last_layers:
|
||||
for layer in layers[:-1]:
|
||||
|
|
|
|||
|
|
@ -58,6 +58,38 @@ cli:
|
|||
hidden: true
|
||||
|
||||
read_write: false # {_('Configuration in output step is in read_write mode')}
|
||||
|
||||
inaccessible_read_write_modes:
|
||||
description: {_('Modes that should not be accessible in read_write mode')}
|
||||
multi: true
|
||||
mandatory: false
|
||||
disabled:
|
||||
jinja: |
|
||||
{{% if not modes_level %}}
|
||||
No mode
|
||||
{{% endif %}}
|
||||
validators:
|
||||
- type: jinja
|
||||
jinja: |
|
||||
{{% if _.inaccessible_read_write_modes not in modes_level %}}
|
||||
not in modes_level ({{modes_level}})
|
||||
{{% endif %}}
|
||||
|
||||
inaccessible_modes:
|
||||
description: {_('Modes that should not be accessible')}
|
||||
multi: true
|
||||
mandatory: false
|
||||
disabled:
|
||||
jinja: |
|
||||
{{% if not modes_level %}}
|
||||
No mode
|
||||
{{% endif %}}
|
||||
validators:
|
||||
- type: jinja
|
||||
jinja: |
|
||||
{{% if _.inaccessible_modes not in modes_level %}}
|
||||
not in modes_level ({{modes_level}})
|
||||
{{% endif %}}
|
||||
"""
|
||||
return {
|
||||
"options": options,
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
"[cols=\"1a,1a\"]\n|====\n| Variable | Description \n| \n\n**my_variable** +\n`https://rougail.readthedocs.io/en/latest/variable.html#variables-types[string]` `mandatory` | \nA description. +\n**Default**: my_value \n|====\n\n"
|
||||
"[cols=\"1a,1a\"]\n|====\n| Variable | Description \n| **my_variable** +\n`https://rougail.readthedocs.io/en/latest/variable.html#variables-types[string]` `mandatory` | A description. +\n**Default**: my_value \n|====\n\n"
|
||||
Loading…
Reference in a new issue