-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set image default tag on pull #2671
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -395,12 +395,12 @@ def load(self, data): | |
|
||
return [self.get(i) for i in images] | ||
|
||
def pull(self, repository, tag=None, **kwargs): | ||
def pull(self, repository, tag=None, all_tags=False, **kwargs): | ||
""" | ||
Pull an image of the given name and return it. Similar to the | ||
``docker pull`` command. | ||
If no tag is specified, all tags from that repository will be | ||
pulled. | ||
If ``all_tags`` is set, the ``tag`` parameter is ignored and all image | ||
tags will be pulled. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even though it's intuitive, it's probably good to add explicit documentation that if |
||
|
||
If you want to get the raw pull output, use the | ||
:py:meth:`~docker.api.image.ImageApiMixin.pull` method in the | ||
|
@@ -413,10 +413,11 @@ def pull(self, repository, tag=None, **kwargs): | |
config for this request. ``auth_config`` should contain the | ||
``username`` and ``password`` keys to be valid. | ||
platform (str): Platform in the format ``os[/arch[/variant]]`` | ||
all_tags (bool): Pull all image tags | ||
|
||
Returns: | ||
(:py:class:`Image` or list): The image that has been pulled. | ||
If no ``tag`` was specified, the method will return a list | ||
If ``tag`` is None, the method will return a list | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this comment needs updating. Should it be something like this?
|
||
of :py:class:`Image` objects belonging to this repository. | ||
|
||
Raises: | ||
|
@@ -426,13 +427,13 @@ def pull(self, repository, tag=None, **kwargs): | |
Example: | ||
|
||
>>> # Pull the image tagged `latest` in the busybox repo | ||
>>> image = client.images.pull('busybox:latest') | ||
>>> image = client.images.pull('busybox') | ||
|
||
>>> # Pull all tags in the busybox repo | ||
>>> images = client.images.pull('busybox') | ||
>>> images = client.images.pull('busybox', all_tags=True) | ||
""" | ||
if not tag: | ||
repository, tag = parse_repository_tag(repository) | ||
repository, image_tag = parse_repository_tag(repository) | ||
tag = tag or image_tag or 'latest' | ||
|
||
if 'stream' in kwargs: | ||
warnings.warn( | ||
|
@@ -442,14 +443,14 @@ def pull(self, repository, tag=None, **kwargs): | |
del kwargs['stream'] | ||
|
||
pull_log = self.client.api.pull( | ||
repository, tag=tag, stream=True, **kwargs | ||
repository, tag=tag, stream=True, all_tags=all_tags, **kwargs | ||
) | ||
for _ in pull_log: | ||
# We don't do anything with the logs, but we need | ||
# to keep the connection alive and wait for the image | ||
# to be pulled. | ||
pass | ||
if tag: | ||
if not all_tags: | ||
return self.get('{0}{2}{1}'.format( | ||
repository, tag, '@' if tag.startswith('sha256:') else ':' | ||
)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wording of the docstring should be updated to make it more clear. E.g.:
should be