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
11463016
Kaydet (Commit)
11463016
authored
Kas 27, 2018
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Correctly handle longpath prefix in process_dockerfile when joining paths
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
f3231a1e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
2 deletions
+72
-2
build.py
docker/api/build.py
+8
-1
constants.py
docker/constants.py
+1
-0
api_build_test.py
tests/unit/api_build_test.py
+63
-1
No files found.
docker/api/build.py
Dosyayı görüntüle @
11463016
...
...
@@ -339,7 +339,14 @@ def process_dockerfile(dockerfile, path):
abs_dockerfile
=
dockerfile
if
not
os
.
path
.
isabs
(
dockerfile
):
abs_dockerfile
=
os
.
path
.
join
(
path
,
dockerfile
)
if
constants
.
IS_WINDOWS_PLATFORM
and
path
.
startswith
(
constants
.
WINDOWS_LONGPATH_PREFIX
):
abs_dockerfile
=
'{}{}'
.
format
(
constants
.
WINDOWS_LONGPATH_PREFIX
,
os
.
path
.
normpath
(
abs_dockerfile
[
len
(
constants
.
WINDOWS_LONGPATH_PREFIX
):]
)
)
if
(
os
.
path
.
splitdrive
(
path
)[
0
]
!=
os
.
path
.
splitdrive
(
abs_dockerfile
)[
0
]
or
os
.
path
.
relpath
(
abs_dockerfile
,
path
)
.
startswith
(
'..'
)):
# Dockerfile not in context - read data to insert into tar later
...
...
docker/constants.py
Dosyayı görüntüle @
11463016
...
...
@@ -14,6 +14,7 @@ INSECURE_REGISTRY_DEPRECATION_WARNING = \
'is deprecated and non-functional. Please remove it.'
IS_WINDOWS_PLATFORM
=
(
sys
.
platform
==
'win32'
)
WINDOWS_LONGPATH_PREFIX
=
'
\\\\
?
\\
'
DEFAULT_USER_AGENT
=
"docker-sdk-python/{0}"
.
format
(
version
)
DEFAULT_NUM_POOLS
=
25
...
...
tests/unit/api_build_test.py
Dosyayı görüntüle @
11463016
import
gzip
import
io
import
shutil
import
docker
from
docker
import
auth
from
docker.api.build
import
process_dockerfile
from
.api_test
import
BaseAPIClientTest
,
fake_request
,
url_prefix
import
pytest
from
..helpers
import
make_tree
from
.api_test
import
BaseAPIClientTest
,
fake_request
,
url_prefix
class
BuildTest
(
BaseAPIClientTest
):
def
test_build_container
(
self
):
...
...
@@ -161,3 +165,61 @@ class BuildTest(BaseAPIClientTest):
self
.
client
.
_set_auth_headers
(
headers
)
assert
headers
==
expected_headers
@pytest.mark.skipif
(
not
docker
.
constants
.
IS_WINDOWS_PLATFORM
,
reason
=
'Windows-specific syntax'
)
def
test_process_dockerfile_win_longpath_prefix
(
self
):
dirs
=
[
'foo'
,
'foo/bar'
,
'baz'
,
]
files
=
[
'Dockerfile'
,
'foo/Dockerfile.foo'
,
'foo/bar/Dockerfile.bar'
,
'baz/Dockerfile.baz'
,
]
base
=
make_tree
(
dirs
,
files
)
self
.
addCleanup
(
shutil
.
rmtree
,
base
)
def
pre
(
path
):
return
docker
.
constants
.
WINDOWS_LONGPATH_PREFIX
+
path
assert
process_dockerfile
(
None
,
pre
(
base
))
==
(
None
,
None
)
assert
process_dockerfile
(
'Dockerfile'
,
pre
(
base
))
==
(
'Dockerfile'
,
None
)
assert
process_dockerfile
(
'foo/Dockerfile.foo'
,
pre
(
base
))
==
(
'foo/Dockerfile.foo'
,
None
)
assert
process_dockerfile
(
'../Dockerfile'
,
pre
(
base
+
'
\\
foo'
)
)[
1
]
is
not
None
assert
process_dockerfile
(
'../baz/Dockerfile.baz'
,
pre
(
base
+
'/baz'
)
)
==
(
'../baz/Dockerfile.baz'
,
None
)
def
test_process_dockerfile
(
self
):
dirs
=
[
'foo'
,
'foo/bar'
,
'baz'
,
]
files
=
[
'Dockerfile'
,
'foo/Dockerfile.foo'
,
'foo/bar/Dockerfile.bar'
,
'baz/Dockerfile.baz'
,
]
base
=
make_tree
(
dirs
,
files
)
self
.
addCleanup
(
shutil
.
rmtree
,
base
)
assert
process_dockerfile
(
None
,
base
)
==
(
None
,
None
)
assert
process_dockerfile
(
'Dockerfile'
,
base
)
==
(
'Dockerfile'
,
None
)
assert
process_dockerfile
(
'foo/Dockerfile.foo'
,
base
)
==
(
'foo/Dockerfile.foo'
,
None
)
assert
process_dockerfile
(
'../Dockerfile'
,
base
+
'/foo'
)[
1
]
is
not
None
assert
process_dockerfile
(
'../baz/Dockerfile.baz'
,
base
+
'/baz'
)
==
(
'../baz/Dockerfile.baz'
,
None
)
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