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:
Felix Fontein
2021-02-24 23:45:34 +01:00
committed by GitHub
parent f107ab281f
commit ed9bf1117f
4 changed files with 52 additions and 15 deletions
+9 -2
View File
@@ -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'):