-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -395,12 +395,13 @@ 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 ``tag`` is ``None`` or empty, it is set to ``latest``. | ||
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 +414,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 ``all_tags`` is True, the method will return a list | ||
of :py:class:`Image` objects belonging to this repository. | ||
|
||
Raises: | ||
|
@@ -426,13 +428,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 +444,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 ':' | ||
)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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