Skip to content

Commit

Permalink
Adjust docker_image_load module.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Jun 24, 2022
1 parent bf3bcc8 commit 33a5d32
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions plugins/modules/docker_image_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@
required: true
extends_documentation_fragment:
- community.docker.docker
- community.docker.docker.docker_py_2_documentation
- community.docker.docker.api_documentation
notes:
- Does not support C(check_mode).
requirements:
- "L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 2.5.0"
- "Docker API >= 1.23"
author:
Expand Down Expand Up @@ -75,7 +73,7 @@

from ansible.module_utils.common.text.converters import to_native

from ansible_collections.community.docker.plugins.module_utils.common import (
from ansible_collections.community.docker.plugins.module_utils.common_api import (
AnsibleDockerClient,
RequestException,
)
Expand All @@ -84,11 +82,7 @@
is_image_name_id,
)

try:
from docker.errors import DockerException
except ImportError:
# missing Docker SDK for Python handled in module_utils.docker.common
pass
from ansible_collections.community.docker.plugins.module_utils._api.errors import DockerException


class ImageManager(DockerBaseClass):
Expand Down Expand Up @@ -125,7 +119,8 @@ def load_images(self):
self.log("Opening image {0}".format(self.path))
with open(self.path, 'rb') as image_tar:
self.log("Loading images from {0}".format(self.path))
for line in self.client.load_image(image_tar):
res = self.client._post(self.client._url("/images/load"), data=image_tar, stream=True)
for line in self.client._stream_helper(res, decode=True):
self.log(line, pretty_print=True)
self._extract_output_line(line, load_output)
except EnvironmentError as exc:
Expand Down Expand Up @@ -168,7 +163,6 @@ def main():
path=dict(type='path', required=True),
),
supports_check_mode=False,
min_docker_version='2.5.0',
min_docker_api_version='1.23',
)

Expand Down

0 comments on commit 33a5d32

Please sign in to comment.