Merge "Use consistent registry type var name across roles"

This commit is contained in:
Zuul 2025-01-28 14:42:33 +00:00 committed by Gerrit Code Review
commit 9edd78d72a
2 changed files with 26 additions and 15 deletions
roles/remove-registry-tag

@ -39,14 +39,19 @@ communicate to using arguments below.
`<https://docs.quay.io/api/>`__
* **docker.io** : Username and password
You can specify the registry type explicitly via the ``type``
attribute, but it will be inferred for quay.io and docker.io.
Example:
.. code-block:: yaml
container_registry_credentials:
quay.io:
type: 'quay'
api_token: 'abcd1234'
docker.io:
type: 'docker'
username: 'username'
password: 'password'
@ -74,16 +79,6 @@ communicate to using arguments below.
:zuul:rolevar:`remove-registry-tag.remove_registry_tag_regex`
last-modified timestamp must exceed to be removed.
.. zuul:rolevar:: remove_registry_tag_api_type
:type: string
Optional. By default the role will guess the API type from the
repository name. However, if you need to override this choice
specify one of:
* quay
* docker
.. zuul:rolevar:: remove_registry_tag_api_url
:type: string

@ -13,15 +13,31 @@
_registry: "{{ (remove_registry_tag_repository | split('/', 1)).0 }}"
_repopath: "{{ (remove_registry_tag_repository | split('/', 1)).1 }}"
- name: Verify registry names
when: |
container_registry_credentials is defined
and _registry not in container_registry_credentials
fail:
msg: "{{ _registry }} credentials not found"
- name: Autoprobe for quay.io
when: remove_registry_tag_api_type is not defined and "quay.io" in _registry
when:
- container_registry_credentials[_registry].type is not defined
- '"quay.io" in _registry'
set_fact:
remove_registry_tag_api_type: "quay"
registry_type: "quay"
- name: Autoprobe for docker
when: remove_registry_tag_api_type is not defined and "docker.io" in _registry
when:
- container_registry_credentials[_registry].type is not defined
- '"docker.io" in _registry'
set_fact:
remove_registry_tag_api_type: "docker"
registry_type: "docker"
- name: Use explicit registry type if set
when: container_registry_credentials[_registry].type is defined
set_fact:
registry_type: container_registry_credentials[_registry].type
- name: Remove tags
include_tasks: '{{ remove_registry_tag_api_type }}.yaml'
include_tasks: '{{ registry_type }}.yaml'