-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build and context_dir option to podman_play (#649)
* Add test for kube_play with image build Signed-off-by: nishipy <goodisonev4@gmail.com> * Add build and context_dir options to podman_play Signed-off-by: nishipy <goodisonev4@gmail.com> * Fix yamllint errors Signed-off-by: nishipy <goodisonev4@gmail.com> * Fix ci errors Signed-off-by: nishipy <goodisonev4@gmail.com> --------- Signed-off-by: nishipy <goodisonev4@gmail.com>
- Loading branch information
Showing
5 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
tests/integration/targets/podman_play/tasks/files/Containerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM ubi8-init | ||
RUN dnf -y install httpd; dnf -y clean all | ||
RUN systemctl enable httpd.service |
21 changes: 21 additions & 0 deletions
21
tests/integration/targets/podman_play/tasks/files/kube-buil-test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Save the output of this file and use kubectl create -f to import | ||
# it into Kubernetes. | ||
# | ||
# Created with podman-4.4.1 | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
org.opencontainers.image.base.digest/buil-test: sha256:e08f47885d5794a7d8b6404e9db9b0c0a9fc6c633da3c3af0c355299 | ||
org.opencontainers.image.base.name/buil-test: registry.redhat.io/ubi8-init:latest | ||
creationTimestamp: "2023-09-28T01:12:34Z" | ||
labels: | ||
app: buil-test-pod | ||
name: buil-test-pod | ||
spec: | ||
containers: | ||
- image: localhost/build-test:latest | ||
name: buil-test | ||
ports: | ||
- containerPort: 80 | ||
hostPort: 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
tests/integration/targets/podman_play/tasks/play-with-build.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
- name: Test play kube with on-demand image build | ||
vars: | ||
image_name: build-test | ||
build_context_dir: /tmp/contextdir | ||
kube_dir: /tmp | ||
success_msg: "Successfully tagged localhost/{{ image_name }}:latest" | ||
block: | ||
|
||
- name: Make sure that {{ image_name }} image is absent | ||
containers.podman.podman_image: | ||
name: "{{ image_name }}" | ||
state: absent | ||
|
||
- name: Copy files to known place | ||
copy: | ||
src: kube-buil-test.yaml | ||
dest: "{{ kube_dir }}/kube-buil-test.yaml" | ||
remote_src: false | ||
|
||
- name: Create context dir for build | ||
file: | ||
path: "{{ build_context_dir }}/{{ image_name }}" | ||
state: directory | ||
|
||
- name: Copy Containerfile for build | ||
copy: | ||
src: Containerfile | ||
dest: "{{ build_context_dir }}/{{ image_name }}/Containerfile" | ||
remote_src: false | ||
|
||
- name: Play kube file with image build | ||
containers.podman.podman_play: | ||
kube_file: "{{ kube_dir }}/kube-buil-test.yaml" | ||
build: true | ||
context_dir: "{{ build_context_dir }}" | ||
state: started | ||
register: play_with_build | ||
|
||
- name: Check if the result is changed | ||
assert: | ||
that: | ||
- play_with_build is changed | ||
- success_msg in play_with_build.stdout | ||
|
||
always: | ||
|
||
- name: Cleanup pods | ||
containers.podman.podman_play: | ||
kube_file: "{{ kube_dir }}/kube-buil-test.yaml" | ||
state: absent |