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
7dce1291
Kaydet (Commit)
7dce1291
authored
Eyl 01, 2015
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #754 from aanand/default-to-tcp-url-on-windows
Default to 127.0.0.1:2375 on Windows
üst
c485bd8d
1362938f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
6 deletions
+19
-6
clientbase.py
docker/clientbase.py
+2
-1
utils.py
docker/utils/utils.py
+5
-1
utils_test.py
tests/utils_test.py
+12
-4
No files found.
docker/clientbase.py
Dosyayı görüntüle @
7dce1291
import
json
import
struct
import
sys
import
requests
import
requests.exceptions
...
...
@@ -31,7 +32,7 @@ class ClientBase(requests.Session):
self
.
_auth_configs
=
auth
.
load_config
()
base_url
=
utils
.
parse_host
(
base_url
)
base_url
=
utils
.
parse_host
(
base_url
,
sys
.
platform
)
if
base_url
.
startswith
(
'http+unix://'
):
self
.
_custom_adapter
=
unixconn
.
UnixAdapter
(
base_url
,
timeout
)
self
.
mount
(
'http+docker://'
,
self
.
_custom_adapter
)
...
...
docker/utils/utils.py
Dosyayı görüntüle @
7dce1291
...
...
@@ -272,11 +272,15 @@ def parse_repository_tag(repo):
# fd:// protocol unsupported (for obvious reasons)
# Added support for http and https
# Protocol translation: tcp -> http, unix -> http+unix
def
parse_host
(
addr
):
def
parse_host
(
addr
,
platform
=
None
):
proto
=
"http+unix"
host
=
DEFAULT_HTTP_HOST
port
=
None
path
=
''
if
not
addr
and
platform
==
'win32'
:
addr
=
'{0}:{1}'
.
format
(
DEFAULT_HTTP_HOST
,
2375
)
if
not
addr
or
addr
.
strip
()
==
'unix://'
:
return
DEFAULT_UNIX_SOCKET
...
...
tests/utils_test.py
Dosyayı görüntüle @
7dce1291
...
...
@@ -79,8 +79,6 @@ class UtilsTest(base.BaseTestCase):
'tcp://:7777'
:
'http://127.0.0.1:7777'
,
'http://:7777'
:
'http://127.0.0.1:7777'
,
'https://kokia.jp:2375'
:
'https://kokia.jp:2375'
,
''
:
'http+unix://var/run/docker.sock'
,
None
:
'http+unix://var/run/docker.sock'
,
'unix:///var/run/docker.sock'
:
'http+unix:///var/run/docker.sock'
,
'unix://'
:
'http+unix://var/run/docker.sock'
,
'somehost.net:80/service/swarm'
:
(
...
...
@@ -90,10 +88,20 @@ class UtilsTest(base.BaseTestCase):
for
host
in
invalid_hosts
:
with
pytest
.
raises
(
DockerException
):
parse_host
(
host
)
parse_host
(
host
,
None
)
for
host
,
expected
in
valid_hosts
.
items
():
self
.
assertEqual
(
parse_host
(
host
),
expected
,
msg
=
host
)
self
.
assertEqual
(
parse_host
(
host
,
None
),
expected
,
msg
=
host
)
def
test_parse_host_empty_value
(
self
):
unix_socket
=
'http+unix://var/run/docker.sock'
tcp_port
=
'http://127.0.0.1:2375'
for
val
in
[
None
,
''
]:
for
platform
in
[
'darwin'
,
'linux2'
,
None
]:
assert
parse_host
(
val
,
platform
)
==
unix_socket
assert
parse_host
(
val
,
'win32'
)
==
tcp_port
def
test_kwargs_from_env_empty
(
self
):
os
.
environ
.
update
(
DOCKER_HOST
=
''
,
...
...
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