Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
2e8f1f79
Unverified
Kaydet (Commit)
2e8f1f79
authored
Ock 31, 2018
tarafından
Joffrey F
Kaydeden (comit)
GitHub
Ock 31, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #1883 from docker/1761-dockerclient-pull
Properly support pulling all tags in DockerClient.images.pull
üst
a05922e9
17aa3145
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
6 deletions
+40
-6
images.py
docker/models/images.py
+17
-3
models_images_test.py
tests/integration/models_images_test.py
+6
-0
models_services_test.py
tests/integration/models_services_test.py
+2
-1
models_images_test.py
tests/unit/models_images_test.py
+15
-2
No files found.
docker/models/images.py
Dosyayı görüntüle @
2e8f1f79
...
...
@@ -5,6 +5,7 @@ import six
from
..api
import
APIClient
from
..errors
import
BuildError
,
ImageLoadError
from
..utils
import
parse_repository_tag
from
..utils.json_stream
import
json_stream
from
.resource
import
Collection
,
Model
...
...
@@ -269,6 +270,8 @@ class ImageCollection(Collection):
"""
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 you want to get the raw pull output, use the
:py:meth:`~docker.api.image.ImageApiMixin.pull` method in the
...
...
@@ -285,7 +288,9 @@ class ImageCollection(Collection):
platform (str): Platform in the format ``os[/arch[/variant]]``
Returns:
(:py:class:`Image`): The image that has been pulled.
(:py:class:`Image` or list): The image that has been pulled.
If no ``tag`` was specified, the method will return a list
of :py:class:`Image` objects belonging to this repository.
Raises:
:py:class:`docker.errors.APIError`
...
...
@@ -293,10 +298,19 @@ class ImageCollection(Collection):
Example:
>>> image = client.images.pull('busybox')
>>> # Pull the image tagged `latest` in the busybox repo
>>> image = client.images.pull('busybox:latest')
>>> # Pull all tags in the busybox repo
>>> images = client.images.pull('busybox')
"""
if
not
tag
:
name
,
tag
=
parse_repository_tag
(
name
)
self
.
client
.
api
.
pull
(
name
,
tag
=
tag
,
**
kwargs
)
return
self
.
get
(
'{0}:{1}'
.
format
(
name
,
tag
)
if
tag
else
name
)
if
tag
:
return
self
.
get
(
'{0}:{1}'
.
format
(
name
,
tag
))
return
self
.
list
(
name
)
def
push
(
self
,
repository
,
tag
=
None
,
**
kwargs
):
return
self
.
client
.
api
.
push
(
repository
,
tag
=
tag
,
**
kwargs
)
...
...
tests/integration/models_images_test.py
Dosyayı görüntüle @
2e8f1f79
...
...
@@ -74,6 +74,12 @@ class ImageCollectionTest(BaseIntegrationTest):
image
=
client
.
images
.
pull
(
'alpine'
,
tag
=
'3.3'
)
assert
'alpine:3.3'
in
image
.
attrs
[
'RepoTags'
]
def
test_pull_multiple
(
self
):
client
=
docker
.
from_env
(
version
=
TEST_API_VERSION
)
images
=
client
.
images
.
pull
(
'hello-world'
)
assert
len
(
images
)
==
1
assert
'hello-world:latest'
in
images
[
0
]
.
attrs
[
'RepoTags'
]
def
test_load_error
(
self
):
client
=
docker
.
from_env
(
version
=
TEST_API_VERSION
)
with
pytest
.
raises
(
docker
.
errors
.
ImageLoadError
):
...
...
tests/integration/models_services_test.py
Dosyayı görüntüle @
2e8f1f79
import
unittest
import
docker
import
pytest
from
..
import
helpers
from
.base
import
TEST_API_VERSION
from
docker.errors
import
InvalidArgument
from
docker.types.services
import
ServiceMode
import
pytest
class
ServiceTest
(
unittest
.
TestCase
):
...
...
@@ -182,6 +182,7 @@ class ServiceTest(unittest.TestCase):
service
.
reload
()
assert
not
service
.
attrs
[
'Spec'
]
.
get
(
'Labels'
)
@pytest.mark.xfail
(
reason
=
'Flaky test'
)
def
test_update_retains_networks
(
self
):
client
=
docker
.
from_env
(
version
=
TEST_API_VERSION
)
network_name
=
helpers
.
random_name
()
...
...
tests/unit/models_images_test.py
Dosyayı görüntüle @
2e8f1f79
...
...
@@ -41,9 +41,22 @@ class ImageCollectionTest(unittest.TestCase):
def
test_pull
(
self
):
client
=
make_fake_client
()
image
=
client
.
images
.
pull
(
'test_image'
)
image
=
client
.
images
.
pull
(
'test_image:latest'
)
client
.
api
.
pull
.
assert_called_with
(
'test_image'
,
tag
=
'latest'
)
client
.
api
.
inspect_image
.
assert_called_with
(
'test_image:latest'
)
assert
isinstance
(
image
,
Image
)
assert
image
.
id
==
FAKE_IMAGE_ID
def
test_pull_multiple
(
self
):
client
=
make_fake_client
()
images
=
client
.
images
.
pull
(
'test_image'
)
client
.
api
.
pull
.
assert_called_with
(
'test_image'
,
tag
=
None
)
client
.
api
.
inspect_image
.
assert_called_with
(
'test_image'
)
client
.
api
.
images
.
assert_called_with
(
all
=
False
,
name
=
'test_image'
,
filters
=
None
)
client
.
api
.
inspect_image
.
assert_called_with
(
FAKE_IMAGE_ID
)
assert
len
(
images
)
==
1
image
=
images
[
0
]
assert
isinstance
(
image
,
Image
)
assert
image
.
id
==
FAKE_IMAGE_ID
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment