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
Conversation
Looks like a duplicate of #2656 |
With this change, will it still be possible to achieve the "pull all tags" behavior? (i.e. to implement "docker pull --all-tags ..." ? |
8083aee
to
1f4a790
Compare
Oops, don't think so. Let me try something else. |
a42be80
to
e89a080
Compare
@@ -395,7 +395,7 @@ def load(self, data): | |||
|
|||
return [self.get(i) for i in images] | |||
|
|||
def pull(self, repository, tag=None, **kwargs): | |||
def pull(self, repository, tag='latest', **kwargs): | |||
""" | |||
Pull an image of the given name and return it. Similar to the | |||
``docker pull`` command. |
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.:
If no tag is specified, all tags from that repository will be pulled.
should be
If tag is None, all tags from that repository will be pulled.
b67e580
to
1d09f93
Compare
docker/api/image.py
Outdated
@@ -342,14 +342,14 @@ def prune_images(self, filters=None): | |||
params['filters'] = utils.convert_filters(filters) | |||
return self._result(self._post(url, params=params), True) | |||
|
|||
def pull(self, repository, tag=None, stream=False, auth_config=None, | |||
def pull(self, repository, tag='latest', stream=False, auth_config=None, |
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.
Thinking out loud: would it work to add an all_tags
parameter, and based on that either keep None
as None
, or set None -> latest
?
Train of thought is that if you want to pull all tags, no tag
is allowed to be set, so it feels a bit more natural to having a separate option (the original "no tag means all tags" is a bit awkward, and, well, bad choices in the past)
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.
@thaJeztah I added an all_tags
parameter to the pull methods. Is the logic ok? If we set it, we ignore any tag set with tag
or repository
parameter.
Signed-off-by: aiordache <anca.iordache@docker.com>
1c73240
to
cec152d
Compare
docker/models/images.py
Outdated
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment needs updating. Should it be something like this?
The image that has been pulled. If
all_tags
is True, then the method will return a list of :py:class:Image
objects belonging to this repository.
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 comment
The 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 tag
is None
or empty, then it will be set to "latest"
. Also in the api.image
module.
Signed-off-by: aiordache <anca.iordache@docker.com>
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.
LGTM
@thaJeztah PTAL |
Set default tag to
latest
on pull.Resolves #2545