k8s-infra-cherrypick-robot 5979110c2c
cri-o: fix duplicate top-level "auths" keys in registry config template (#12885)
The config.json.j2 template was generating invalid JSON when multiple
crio_registry_auth entries were defined, resulting in multiple top-level
"auths" objects being rendered, e.g.:

{
  "auths": { "registry1": { "auth": "xxxx" } },
  "auths": { "registry2": { "auth": "yyyy" } }
}

This change moves the loop inside the "auths" object so that all registries
are rendered as siblings under a single "auths" key, producing valid JSON:

{
  "auths": {
    "registry1": { "auth": "xxxx" },
    "registry2": { "auth": "yyyy" }
  }
}

Co-authored-by: Martin Cahill <martin.cahill@gmail.com>
2026-01-20 19:58:51 +05:30

18 lines
331 B
Django/Jinja

{% if crio_registry_auth is defined and crio_registry_auth|length %}
{
"auths": {
{% for reg in crio_registry_auth %}
"{{ reg.registry }}": {
"auth": "{{ (reg.username + ':' + reg.password) | string | b64encode }}"
{% if not loop.last %}
},
{% else %}
}
{% endif %}
{% endfor %}
}
}
{% else %}
{}
{% endif %}