Fix docker_image's build.args (#456)

* Add tests for build.args.

* Fix bug: store build args in correct dict

* Add changelog fragment.

* Update copyright notice.
This commit is contained in:
Felix Fontein 2022-08-16 22:37:51 +02:00 committed by GitHub
parent ad05773e34
commit d8297df7d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 1 deletions

View File

@ -0,0 +1,2 @@
bugfixes:
- "docker_image - fix build argument handling (https://github.com/ansible-collections/community.docker/issues/455, https://github.com/ansible-collections/community.docker/pull/456)."

View File

@ -696,7 +696,7 @@ class ImageManager(DockerBaseClass):
buildargs = {}
if self.buildargs:
for key, value in self.buildargs.items():
self.buildargs[key] = to_native(value)
buildargs[key] = to_native(value)
container_limits = self.container_limits or {}
for key in container_limits.keys():

View File

@ -24,6 +24,7 @@
src: '{{ item }}'
dest: '{{ remote_tmp_dir }}/files/{{ item }}'
loop:
- ArgsDockerfile
- Dockerfile
- EtcHostsDockerfile
- MyDockerfile

View File

@ -27,7 +27,9 @@
name: "{{ iname }}"
build:
path: "{{ remote_tmp_dir }}/files"
dockerfile: "ArgsDockerfile"
args:
IMAGE: "{{ docker_test_image_busybox }}"
TEST1: val1
TEST2: val2
TEST3: "True"
@ -41,7 +43,9 @@
name: "{{ iname }}"
build:
path: "{{ remote_tmp_dir }}/files"
dockerfile: "ArgsDockerfile"
args:
IMAGE: "{{ docker_test_image_busybox }}"
TEST1: val1
TEST2: val2
TEST3: "True"

View File

@ -0,0 +1,13 @@
# Copyright (c) 2022, Felix Fontein
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
ARG IMAGE
ARG TEST1
ARG TEST2
ARG TEST3
FROM ${IMAGE}
ENV foo /bar
WORKDIR ${foo}
RUN echo "${TEST1} - ${TEST2} - ${TEST3}"