mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 11:55:04 +00:00
docker_image: allow to specify pull platform (#89)
* Allow to specify pull platform. * Add basic test and document that the value is not used for idempotency at the moment. * Fix pulling. * Simplify code. * Add API version for pull_platform. * Move pull_platform into new pull option. Use apply_defaults=True to avoid some special logic. * Add example. * Remove apply_defaults=True.
This commit is contained in:
@@ -578,14 +578,21 @@ class AnsibleDockerClientBase(Client):
|
||||
break
|
||||
return images
|
||||
|
||||
def pull_image(self, name, tag="latest"):
|
||||
def pull_image(self, name, tag="latest", platform=None):
|
||||
'''
|
||||
Pull an image
|
||||
'''
|
||||
kwargs = dict(
|
||||
tag=tag,
|
||||
stream=True,
|
||||
decode=True,
|
||||
)
|
||||
if platform is not None:
|
||||
kwargs['platform'] = platform
|
||||
self.log("Pulling image %s:%s" % (name, tag))
|
||||
old_tag = self.find_image(name, tag)
|
||||
try:
|
||||
for line in self.pull(name, tag=tag, stream=True, decode=True):
|
||||
for line in self.pull(name, **kwargs):
|
||||
self.log(line, pretty_print=True)
|
||||
if line.get('error'):
|
||||
if line.get('errorDetail'):
|
||||
|
||||
Reference in New Issue
Block a user