docker_image: do not crash in load_image for docker-py < 2.5.0. (#73)

* Avoid crash for docker-py < 2.5.0.

* Add warnings when load_image does not return a generator.

* Add test.

* Update plugins/modules/docker_image.py

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>

Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
This commit is contained in:
Felix Fontein
2021-01-25 15:17:04 +01:00
committed by GitHub
parent c1e6c2e699
commit 8702713ac3
3 changed files with 60 additions and 20 deletions
@@ -282,6 +282,14 @@
register: load_image_3
ignore_errors: true
- name: load image (invalid image, old API version)
docker_image:
name: foo:bar
load_path: "{{ output_dir }}/image-invalid.tar"
source: load
api_version: "1.22"
register: load_image_4
- assert:
that:
- load_image is changed
@@ -292,6 +300,8 @@
"The archive did not contain image 'foo:bar'. Instead, found '" ~ docker_test_image_hello_world ~ "'." == load_image_2.msg
- load_image_3 is failed
- '"Detected no loaded images. Archive potentially corrupt?" == load_image_3.msg'
- load_image_4 is changed
- "'The API version of your Docker daemon is < 1.23, which does not return the image loading result from the Docker daemon. Therefore, we cannot verify whether the expected image was loaded, whether multiple images where loaded, or whether the load actually succeeded. You should consider upgrading your Docker daemon.' in load_image_4.warnings"
####################################################################
## build.path ######################################################