fix: add multiple value type in service vars
This commit is contained in:
parent
e3a7c76773
commit
2dd145bede
1 changed files with 20 additions and 2 deletions
|
@ -20,9 +20,27 @@ apply Service "{{ name }}" {
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if service.vars is defined %}
|
{% if service.vars is defined %}
|
||||||
|
|
||||||
{% for var_name, value in service.vars.items() %}
|
{% for var, value in service.vars.items() %}
|
||||||
vars.{{ var_name }} = {% if value is number %}{{ value }}{% else %}"{{ value|replace('\n', ' ') }}"{% endif %}
|
{% if value is sameas True %}
|
||||||
|
vars.{{ var }} = true
|
||||||
|
{% elif value is sameas False %}
|
||||||
|
vars.{{ var }} = false
|
||||||
|
{% elif value is mapping %}
|
||||||
|
{% for name, config in value.items() %}
|
||||||
|
vars.{{ var }}["{{ name }}"] = {
|
||||||
|
{% for option, v in config.items() %}
|
||||||
|
{{ option }} = {% if v is number %}{{ v }}{% else %}"{{ v|replace('\n', ' ')|trim }}"{% endif %}
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
}
|
||||||
|
{% endfor %}
|
||||||
|
{% elif value is iterable and not value is string %}
|
||||||
|
vars.{{ var }} = [ "{{ value|join(', "') }}" ]
|
||||||
|
{% elif value is number or value|regex_search('^[0-9]+(s|m|h|d)$') %}
|
||||||
|
vars.{{ var }} = {{ value }}
|
||||||
|
{% else %}
|
||||||
|
vars.{{ var }} = "{{ value|replace('\n', ' ')|trim }}"
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue