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
1f34b489
Kaydet (Commit)
1f34b489
authored
Tem 12, 2016
tarafından
Aanand Prasad
Kaydeden (comit)
GitHub
Tem 12, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #1119 from Mobelux/fix-build-with-auth
Pass X-Registry-Auth when building an image
üst
5e47026a
e8ea79df
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
4 deletions
+63
-4
build.py
docker/api/build.py
+3
-3
build_test.py
tests/unit/build_test.py
+60
-1
No files found.
docker/api/build.py
Dosyayı görüntüle @
1f34b489
...
...
@@ -18,7 +18,8 @@ class BuildApiMixin(object):
custom_context
=
False
,
encoding
=
None
,
pull
=
False
,
forcerm
=
False
,
dockerfile
=
None
,
container_limits
=
None
,
decode
=
False
,
buildargs
=
None
,
gzip
=
False
):
remote
=
context
=
headers
=
None
remote
=
context
=
None
headers
=
{}
container_limits
=
container_limits
or
{}
if
path
is
None
and
fileobj
is
None
:
raise
TypeError
(
"Either path or fileobj needs to be provided."
)
...
...
@@ -134,8 +135,7 @@ class BuildApiMixin(object):
', '
.
join
(
repr
(
k
)
for
k
in
self
.
_auth_configs
.
keys
())
)
)
if
headers
is
None
:
headers
=
{}
if
utils
.
compare_version
(
'1.19'
,
self
.
_version
)
>=
0
:
headers
[
'X-Registry-Config'
]
=
auth
.
encode_header
(
self
.
_auth_configs
...
...
tests/unit/build_test.py
Dosyayı görüntüle @
1f34b489
...
...
@@ -2,8 +2,9 @@ import gzip
import
io
import
docker
from
docker
import
auth
from
.api_test
import
DockerClientTest
from
.api_test
import
DockerClientTest
,
fake_request
,
url_prefix
class
BuildTest
(
DockerClientTest
):
...
...
@@ -83,8 +84,25 @@ class BuildTest(DockerClientTest):
}
}
expected_params
=
{
't'
:
None
,
'q'
:
False
,
'dockerfile'
:
None
,
'rm'
:
False
,
'nocache'
:
False
,
'pull'
:
False
,
'forcerm'
:
False
,
'remote'
:
'https://github.com/docker-library/mongo'
}
expected_headers
=
{
'X-Registry-Config'
:
auth
.
encode_header
(
self
.
client
.
_auth_configs
)}
self
.
client
.
build
(
path
=
'https://github.com/docker-library/mongo'
)
fake_request
.
assert_called_with
(
'POST'
,
url_prefix
+
'build'
,
stream
=
True
,
data
=
None
,
headers
=
expected_headers
,
params
=
expected_params
,
timeout
=
None
)
def
test_build_container_with_named_dockerfile
(
self
):
self
.
client
.
build
(
'.'
,
dockerfile
=
'nameddockerfile'
)
...
...
@@ -103,3 +121,44 @@ class BuildTest(DockerClientTest):
'foo'
:
'bar'
})
)
def
test_set_auth_headers_with_empty_dict_and_auth_configs
(
self
):
self
.
client
.
_auth_configs
=
{
'https://example.com'
:
{
'user'
:
'example'
,
'password'
:
'example'
,
'email'
:
'example@example.com'
}
}
headers
=
{}
expected_headers
=
{
'X-Registry-Config'
:
auth
.
encode_header
(
self
.
client
.
_auth_configs
)}
self
.
client
.
_set_auth_headers
(
headers
)
self
.
assertEqual
(
headers
,
expected_headers
)
def
test_set_auth_headers_with_dict_and_auth_configs
(
self
):
self
.
client
.
_auth_configs
=
{
'https://example.com'
:
{
'user'
:
'example'
,
'password'
:
'example'
,
'email'
:
'example@example.com'
}
}
headers
=
{
'foo'
:
'bar'
}
expected_headers
=
{
'foo'
:
'bar'
,
'X-Registry-Config'
:
auth
.
encode_header
(
self
.
client
.
_auth_configs
)}
self
.
client
.
_set_auth_headers
(
headers
)
self
.
assertEqual
(
headers
,
expected_headers
)
def
test_set_auth_headers_with_dict_and_no_auth_configs
(
self
):
headers
=
{
'foo'
:
'bar'
}
expected_headers
=
{
'foo'
:
'bar'
}
self
.
client
.
_set_auth_headers
(
headers
)
self
.
assertEqual
(
headers
,
expected_headers
)
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