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
e0b6cdfc
Kaydet (Commit)
e0b6cdfc
authored
Şub 16, 2017
tarafından
Joffrey F
Kaydeden (comit)
GitHub
Şub 16, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #1460 from shin-/fix-cache-from
Rename cachefrom -> cache_from
üst
14caaad6
0a97df1a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
25 deletions
+41
-25
build.py
docker/api/build.py
+8
-7
images.py
docker/models/images.py
+4
-3
api_build_test.py
tests/integration/api_build_test.py
+29
-15
No files found.
docker/api/build.py
Dosyayı görüntüle @
e0b6cdfc
import
json
import
logging
import
os
import
re
import
json
from
..
import
auth
from
..
import
constants
from
..
import
errors
from
..
import
auth
from
..
import
utils
...
...
@@ -18,7 +18,7 @@ class BuildApiMixin(object):
custom_context
=
False
,
encoding
=
None
,
pull
=
False
,
forcerm
=
False
,
dockerfile
=
None
,
container_limits
=
None
,
decode
=
False
,
buildargs
=
None
,
gzip
=
False
,
shmsize
=
None
,
labels
=
None
,
cachefrom
=
None
):
labels
=
None
,
cache
_
from
=
None
):
"""
Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
needs to be set. ``path`` can be a local path (to a directory
...
...
@@ -92,7 +92,8 @@ class BuildApiMixin(object):
shmsize (int): Size of `/dev/shm` in bytes. The size must be
greater than 0. If omitted the system uses 64MB.
labels (dict): A dictionary of labels to set on the image.
cachefrom (list): A list of images used for build cache resolution.
cache_from (list): A list of images used for build cache
resolution.
Returns:
A generator for the build output.
...
...
@@ -189,12 +190,12 @@ class BuildApiMixin(object):
'labels was only introduced in API version 1.23'
)
if
cachefrom
:
if
cache
_
from
:
if
utils
.
version_gte
(
self
.
_version
,
'1.25'
):
params
.
update
({
'cachefrom'
:
json
.
dumps
(
cachefrom
)})
params
.
update
({
'cachefrom'
:
json
.
dumps
(
cache
_
from
)})
else
:
raise
errors
.
InvalidVersion
(
'cachefrom was only introduced in API version 1.25'
'cache
_
from was only introduced in API version 1.25'
)
if
context
is
not
None
:
...
...
docker/models/images.py
Dosyayı görüntüle @
e0b6cdfc
...
...
@@ -141,7 +141,8 @@ class ImageCollection(Collection):
``"0-3"``, ``"0,1"``
decode (bool): If set to ``True``, the returned stream will be
decoded into dicts on the fly. Default ``False``.
cachefrom (list): A list of images used for build cache resolution.
cache_from (list): A list of images used for build cache
resolution.
Returns:
(:py:class:`Image`): The built image.
...
...
@@ -162,10 +163,10 @@ class ImageCollection(Collection):
return
BuildError
(
'Unknown'
)
event
=
events
[
-
1
]
if
'stream'
in
event
:
match
=
re
.
search
(
r'
Successfully built
([0-9a-f]+)'
,
match
=
re
.
search
(
r'
(Successfully built |sha256:)
([0-9a-f]+)'
,
event
.
get
(
'stream'
,
''
))
if
match
:
image_id
=
match
.
group
(
1
)
image_id
=
match
.
group
(
2
)
return
self
.
get
(
image_id
)
raise
BuildError
(
event
.
get
(
'error'
)
or
event
)
...
...
tests/integration/api_build_test.py
Dosyayı görüntüle @
e0b6cdfc
...
...
@@ -3,13 +3,12 @@ import os
import
shutil
import
tempfile
import
pytest
import
six
from
docker
import
errors
from
..helpers
import
requires_api_version
import
six
from
.base
import
BaseAPIIntegrationTest
from
..helpers
import
requires_api_version
class
BuildTest
(
BaseAPIIntegrationTest
):
...
...
@@ -155,25 +154,40 @@ class BuildTest(BaseAPIIntegrationTest):
self
.
assertEqual
(
info
[
'Config'
][
'Labels'
],
labels
)
@requires_api_version
(
'1.25'
)
@pytest.mark.xfail
(
reason
=
'Bad test'
)
def
test_build_cachefrom
(
self
):
def
test_build_with_cache_from
(
self
):
script
=
io
.
BytesIO
(
'
\n
'
.
join
([
'FROM scratch'
,
'CMD sh -c "echo
\'
Hello, World!
\'
"'
,
'FROM busybox'
,
'ENV FOO=bar'
,
'RUN touch baz'
,
'RUN touch bax'
,
])
.
encode
(
'ascii'
))
cachefrom
=
[
'build1'
]
stream
=
self
.
client
.
build
(
fileobj
=
script
,
tag
=
'build1'
)
self
.
tmp_imgs
.
append
(
'build1'
)
for
chunk
in
stream
:
pass
stream
=
self
.
client
.
build
(
fileobj
=
script
,
tag
=
'cachefrom'
,
cachefrom
=
cachefrom
fileobj
=
script
,
tag
=
'build2'
,
cache_from
=
[
'build1'
],
decode
=
True
)
self
.
tmp_imgs
.
append
(
'cachefrom'
)
self
.
tmp_imgs
.
append
(
'build2'
)
counter
=
0
for
chunk
in
stream
:
pass
if
'Using cache'
in
chunk
.
get
(
'stream'
,
''
):
counter
+=
1
assert
counter
==
3
self
.
client
.
remove_image
(
'build2'
)
info
=
self
.
client
.
inspect_image
(
'cachefrom'
)
# FIXME: Config.CacheFrom is not a real thing
self
.
assertEqual
(
info
[
'Config'
][
'CacheFrom'
],
cachefrom
)
counter
=
0
stream
=
self
.
client
.
build
(
fileobj
=
script
,
tag
=
'build2'
,
cache_from
=
[
'nosuchtag'
],
decode
=
True
)
for
chunk
in
stream
:
if
'Using cache'
in
chunk
.
get
(
'stream'
,
''
):
counter
+=
1
assert
counter
==
0
def
test_build_stderr_data
(
self
):
control_chars
=
[
'
\x1b
[91m'
,
'
\x1b
[0m'
]
...
...
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