cleanup: Cleanup YAML passed to k8s module

Cleanup the YAML passed to the k8s module so it conforms to yaml output
you would expect from yaml.dump. Also refactor the tests to get rid of
duplicate definitions and make use of pytest.mark.parametrize and
yaml.dump.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This commit is contained in:
Felix Matouschek
2024-04-24 11:37:03 +02:00
parent 0531ac6c42
commit e5edf072cc
2 changed files with 69 additions and 78 deletions

View File

@@ -265,12 +265,12 @@ apiVersion: {{ api_version }}
kind: VirtualMachine
metadata:
{% if name %}
name: "{{ name }}"
name: {{ name }}
{% endif %}
{% if generate_name %}
generateName: "{{ generate_name }}"
generateName: {{ generate_name }}
{% endif %}
namespace: "{{ namespace }}"
namespace: {{ namespace }}
{% if annotations %}
annotations:
{{ annotations | to_yaml | indent(4) }}
@@ -280,7 +280,7 @@ metadata:
{{ labels | to_yaml | indent(4) }}
{%- endif %}
spec:
running: {{ running }}
running: {{ running | lower }}
{% if instancetype %}
instancetype:
{{ instancetype | to_yaml | indent(4) }}
@@ -291,7 +291,7 @@ spec:
{%- endif %}
{% if data_volume_templates %}
dataVolumeTemplates:
{{ data_volume_templates | to_yaml | indent(4) }}
{{ data_volume_templates | to_yaml | indent(2) }}
{%- endif %}
template:
{% if annotations or labels %}