arg_validator: accept None as valid input for ArgValidatorList

Users might want to use jinja2 templates to set properties. As such,
it's convenient to accept None as an alias for an empty list.

For exmaple, setting like `"match": {"path": None}` will be allowed by
the role:

        network_connections:
          - name: enp0s8
            type: ethernet
            persistent_state: present
            state: up
            match:
              path:
            ip:
              route_metric4: 10

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
This commit is contained in:
Wen Liang 2021-06-28 06:37:47 -04:00 committed by Gris Ge
parent 71b4ff9357
commit af07c2a58d
2 changed files with 6 additions and 0 deletions

View file

@ -407,6 +407,11 @@ class ArgValidatorList(ArgValidator):
# not supported. If you need that, define a proper list.
value = [s for s in value.split(" ") if s]
if value is None:
# Users might want to use jinja2 templates to set properties. As such,
# it's convenient to accept None as an alias for an empty list
# e.g. setting like `"match": {"path": None}` will be allowed by the role
return []
result = []
for (idx, v) in enumerate(value):
try: