Use full image url in container buildx path

The container roles assume a full image url path and do not work with
shorted names like the docker roles do. The buildx path used the shorted
path when it should use the full path. Fix this.

Change-Id: Icdeee0ebb1c0d280968f425f8560cc5208ebd18d
This commit is contained in:
Clark Boylan 2023-04-21 13:15:58 -07:00
parent b7f983c621
commit 4617d0835a
3 changed files with 13 additions and 17 deletions
roles/build-container-image/tasks
test-playbooks/container

@ -4,10 +4,6 @@
fail: fail:
msg: "{{ zj_image.repository }} must be a full container image url including registry location" msg: "{{ zj_image.repository }} must be a full container image url including registry location"
- name: Parse out repo path from full "url"
set_fact:
_repopath: "{{ (zj_image.repository | split('/', 1)).1 }}"
- name: Set container filename arg - name: Set container filename arg
set_fact: set_fact:
containerfile: "{{ zj_image.container_filename | default(container_filename) | default('') }}" containerfile: "{{ zj_image.container_filename | default(container_filename) | default('') }}"
@ -33,9 +29,9 @@
--build-arg "ZUUL_SIBLINGS={{ zj_image.siblings | join(' ') }}" --build-arg "ZUUL_SIBLINGS={{ zj_image.siblings | join(' ') }}"
{% endif -%} {% endif -%}
{% for tag in zj_image.tags | default(['latest']) -%} {% for tag in zj_image.tags | default(['latest']) -%}
--tag {{ temp_registry.host }}:{{ temp_registry.port }}/{{ _repopath }}:{{ tag }} --tag {{ temp_registry.host }}:{{ temp_registry.port }}/{{ zj_image.repository }}:{{ tag }}
{% if buildset_registry | default(false) -%} {% if buildset_registry | default(false) -%}
--tag {{ buildset_registry_alias }}:{{ buildset_registry.port }}/{{ _repopath }}:{{ tag }} --tag {{ buildset_registry_alias }}:{{ buildset_registry.port }}/{{ zj_image.repository }}:{{ tag }}
{% endif -%} {% endif -%}
{% endfor -%} {% endfor -%}
{% for label in zj_image.labels | default([]) -%} {% for label in zj_image.labels | default([]) -%}
@ -53,7 +49,7 @@
- name: Pull images from temporary registry - name: Pull images from temporary registry
command: >- command: >-
docker pull {{ temp_registry.host }}:{{ temp_registry.port }}/{{ _repopath }}:{{ zj_image_tag }} docker pull {{ temp_registry.host }}:{{ temp_registry.port }}/{{ zj_image.repository }}:{{ zj_image_tag }}
loop: "{{ zj_image.tags | default(['latest']) }}" loop: "{{ zj_image.tags | default(['latest']) }}"
loop_control: loop_control:
loop_var: zj_image_tag loop_var: zj_image_tag
@ -61,7 +57,7 @@
- name: Locally tag for changes so push works later - name: Locally tag for changes so push works later
command: >- command: >-
docker tag docker tag
{{ temp_registry.host }}:{{ temp_registry.port }}/{{ _repopath }}:{{ zj_image_tag }} {{ temp_registry.host }}:{{ temp_registry.port }}/{{ zj_image.repository }}:{{ zj_image_tag }}
{{ zj_image.repository }}:change_{{ zuul.change }}_{{ zj_image_tag }} {{ zj_image.repository }}:change_{{ zuul.change }}_{{ zj_image_tag }}
loop: "{{ zj_image.tags | default(['latest']) }}" loop: "{{ zj_image.tags | default(['latest']) }}"
loop_control: loop_control:
@ -71,7 +67,7 @@
- name: Locally tag for changes so push works later - name: Locally tag for changes so push works later
command: >- command: >-
docker tag docker tag
{{ temp_registry.host }}:{{ temp_registry.port }}/{{ _repopath }}:{{ zj_image_tag }} {{ temp_registry.host }}:{{ temp_registry.port }}/{{ zj_image.repository }}:{{ zj_image_tag }}
{{ zj_image.repository }}:{{ zj_image_tag }} {{ zj_image.repository }}:{{ zj_image_tag }}
loop: "{{ zj_image.tags | default(['latest']) }}" loop: "{{ zj_image.tags | default(['latest']) }}"
loop_control: loop_control:

@ -3,13 +3,13 @@
- name: Set docker_registry cacheable facts - name: Set docker_registry cacheable facts
set_fact: set_fact:
cacheable: true cacheable: true
docker_registry: "127.0.0.1:5200" docker_registry: "localhost"
docker_credentials: docker_credentials:
username: zuul username: zuul
password: testpassword password: testpassword
repository: testrepo repository: testrepo
container_registry_credentials: container_registry_credentials:
127.0.0.1:5200: localhost:
username: zuul username: zuul
password: testpassword password: testpassword
repository: testrepo repository: testrepo
@ -37,7 +37,7 @@
dest: /etc/containers/registries.conf dest: /etc/containers/registries.conf
content: | content: |
[registries.insecure] [registries.insecure]
registries = ['127.0.0.1:5200'] registries = ['localhost']
mode: 0644 mode: 0644
when: container_command == 'podman' when: container_command == 'podman'
@ -46,7 +46,7 @@
vars: vars:
registry: registry:
host: "127.0.0.1" host: "127.0.0.1"
port: 5200 port: 80
username: zuul username: zuul
password: testpassword password: testpassword
container_command: docker container_command: docker

@ -13,15 +13,15 @@
tags: "{{ zuul.tag is defined | ternary([zuul.get('tag', '').split('.')[0], '.'.join(zuul.get('tag', '').split('.')[:2]), zuul.get('tag', '')], ['latest']) }}" tags: "{{ zuul.tag is defined | ternary([zuul.get('tag', '').split('.')[0], '.'.join(zuul.get('tag', '').split('.')[:2]), zuul.get('tag', '')], ['latest']) }}"
_multiarch_container_images: _multiarch_container_images:
- context: test-playbooks/container/docker - context: test-playbooks/container/docker
registry: 127.0.0.1:5200 registry: localhost
repository: 127.0.0.1:5200/testrepo repository: localhost/testrepo
# This is what the Zuul repo uses to tag its releases: # This is what the Zuul repo uses to tag its releases:
tags: "{{ zuul.tag is defined | ternary([zuul.get('tag', '').split('.')[0], '.'.join(zuul.get('tag', '').split('.')[:2]), zuul.get('tag', '')], ['latest']) }}" tags: "{{ zuul.tag is defined | ternary([zuul.get('tag', '').split('.')[0], '.'.join(zuul.get('tag', '').split('.')[:2]), zuul.get('tag', '')], ['latest']) }}"
arch: ['linux/amd64', 'linux/arm64'] arch: ['linux/amd64', 'linux/arm64']
_normal_container_images: _normal_container_images:
- context: test-playbooks/container/docker - context: test-playbooks/container/docker
registry: 127.0.0.1:5200 registry: localhost
repository: 127.0.0.1:5200/testrepo repository: localhost/testrepo
# This is what the Zuul repo uses to tag its releases: # This is what the Zuul repo uses to tag its releases:
tags: "{{ zuul.tag is defined | ternary([zuul.get('tag', '').split('.')[0], '.'.join(zuul.get('tag', '').split('.')[:2]), zuul.get('tag', '')], ['latest']) }}" tags: "{{ zuul.tag is defined | ternary([zuul.get('tag', '').split('.')[0], '.'.join(zuul.get('tag', '').split('.')[:2]), zuul.get('tag', '')], ['latest']) }}"
tasks: tasks: