mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-03-22 02:29:08 +00:00
podman_image: add file parameter for Containerfile location (#492)
* `podman_image`: correct `path` parameter description The `path` parameter is the last parameter when running `podman build ...`. As specified in the manpage, it is defined as the build context, and not necessarily should it contain the Containerfile. Signed-off-by: Yuriy Gabuev <yuriy.gabuev@holoplot.com> * `podman_image`: add `file` parameter for Containerfile location Add the `file` parameter to `podman_image` module which mirrors the `--file` command line argument for `podman build ...`. This parameter specifies the location of the Containerfile to use in case it should be different from the one contained in the build context directory. Signed-off-by: Yuriy Gabuev <yuriy.gabuev@holoplot.com> * `podman_image`: add integration tests for `file` parameter Add tests to ensure that: - building from a directory without a Containerfile (or Dockerfile) fails - specifying the location of Containerfile with `file` parameter works Signed-off-by: Yuriy Gabuev <yuriy.gabuev@holoplot.com> Signed-off-by: Yuriy Gabuev <yuriy.gabuev@holoplot.com>
This commit is contained in:
parent
9531d15d24
commit
dbdac4a52b
2 changed files with 44 additions and 6 deletions
|
|
@ -152,9 +152,9 @@
|
|||
- specific_image2 is not changed
|
||||
- "'v3.3.11' in images.stdout"
|
||||
|
||||
- name: Create a build dir
|
||||
- name: Create a build directory with a subdirectory
|
||||
file:
|
||||
path: /var/tmp/build
|
||||
path: /var/tmp/build/subdir
|
||||
state: directory
|
||||
|
||||
- name: Copy Containerfile
|
||||
|
|
@ -176,18 +176,46 @@
|
|||
path: /var/tmp/build
|
||||
register: oci_build2
|
||||
|
||||
- name: Inspect build image
|
||||
- name: Build OCI image from a directory without Containerfile (should fail)
|
||||
containers.podman.podman_image:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
name: testimage2
|
||||
path: /var/tmp/build/subdir
|
||||
register: oci_build3
|
||||
ignore_errors: true
|
||||
|
||||
- name: Build OCI image, point to location of Containerfile
|
||||
containers.podman.podman_image:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
name: testimage2
|
||||
path: /var/tmp/build/subdir
|
||||
build:
|
||||
file: /var/tmp/build/Dockerfile
|
||||
register: oci_build4
|
||||
|
||||
- name: Inspect first image
|
||||
containers.podman.podman_image_info:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
name: testimage
|
||||
register: testimage_info
|
||||
|
||||
- name: Ensure OCI image was built properly
|
||||
- name: Inspect second image
|
||||
containers.podman.podman_image_info:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
name: testimage2
|
||||
register: testimage2_info
|
||||
|
||||
- name: Ensure OCI images were built properly
|
||||
assert:
|
||||
that:
|
||||
- oci_build1 is changed
|
||||
- oci_build2 is not changed
|
||||
- oci_build3 is not changed
|
||||
- oci_build3 is failed
|
||||
- oci_build4 is changed
|
||||
- "'localhost/testimage:latest' in testimage_info.images[0]['RepoTags'][0]"
|
||||
- "'localhost/testimage2:latest' in testimage2_info.images[0]['RepoTags'][0]"
|
||||
- "'no such file or directory' in oci_build3.msg"
|
||||
|
||||
- name: Build Docker image
|
||||
containers.podman.podman_image:
|
||||
|
|
@ -207,7 +235,7 @@
|
|||
format: docker
|
||||
register: docker_build2
|
||||
|
||||
- name: Inspect build image
|
||||
- name: Inspect built image
|
||||
containers.podman.podman_image_info:
|
||||
executable: "{{ test_executable | default('podman') }}"
|
||||
name: dockerimage
|
||||
|
|
@ -247,4 +275,5 @@
|
|||
- quay.io/coreos/alpine-sh
|
||||
- quay.io/coreos/etcd:v3.3.11
|
||||
- localhost/testimage
|
||||
- localhost/testimage2
|
||||
- localhost/dockerimage
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue