---
apiVersion: v1
kind: List
items:
{% for volume in persistent_volumes %}
- apiVersion: v1
  kind: PersistentVolume
  metadata:
    name: "{{ volume.name }}"
{% if volume.annotations is defined %}
    annotations:
{% for annotation in volume.annotations %}
      {{ annotation }}
{% endfor %}
{% endif %}
{% if volume.labels is defined and volume.labels is mapping %}
    labels:
{% for key,value in volume.labels.items() %}
      {{ key }}: {{ value }}
{% endfor %}
{% endif %}
  spec:
    capacity:
      storage: "{{ volume.capacity }}"
    accessModes: {{ volume.access_modes | lib_utils_to_padded_yaml(2, 2) }}
{% for key in (volume.storage.keys() | list) %}
{% if key != 'claimName' %}
    {{ key }}: {{ volume.storage[key] | lib_utils_to_padded_yaml(3, 2) }}
{% endif %}
{% endfor %}
{% if 'claimName' in volume.storage %}
    claimRef:
      name: {{ volume.storage.claimName }}
      namespace: default
{% endif %}
{% endfor %}
