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
65bebc08
Kaydet (Commit)
65bebc08
authored
Ock 09, 2019
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Style fixes and removed some unused code
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
6969e8be
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
32 deletions
+28
-32
container.py
docker/api/container.py
+4
-2
proxy.py
docker/utils/proxy.py
+0
-16
api_build_test.py
tests/integration/api_build_test.py
+8
-3
api_exec_test.py
tests/integration/api_exec_test.py
+16
-11
No files found.
docker/api/container.py
Dosyayı görüntüle @
65bebc08
...
@@ -410,9 +410,11 @@ class ContainerApiMixin(object):
...
@@ -410,9 +410,11 @@ class ContainerApiMixin(object):
if
isinstance
(
environment
,
dict
):
if
isinstance
(
environment
,
dict
):
environment
=
utils
.
utils
.
format_environment
(
environment
)
environment
=
utils
.
utils
.
format_environment
(
environment
)
if
use_config_proxy
:
if
use_config_proxy
:
environment
=
\
environment
=
self
.
_proxy_configs
.
inject_proxy_environment
(
self
.
_proxy_configs
.
inject_proxy_environment
(
environment
)
environment
)
config
=
self
.
create_container_config
(
config
=
self
.
create_container_config
(
image
,
command
,
hostname
,
user
,
detach
,
stdin_open
,
tty
,
image
,
command
,
hostname
,
user
,
detach
,
stdin_open
,
tty
,
...
...
docker/utils/proxy.py
Dosyayı görüntüle @
65bebc08
...
@@ -9,34 +9,18 @@ class ProxyConfig(dict):
...
@@ -9,34 +9,18 @@ class ProxyConfig(dict):
def
http
(
self
):
def
http
(
self
):
return
self
.
get
(
'http'
)
return
self
.
get
(
'http'
)
@http.setter
def
http
(
self
,
value
):
self
[
'http'
]
=
value
@property
@property
def
https
(
self
):
def
https
(
self
):
return
self
.
get
(
'https'
)
return
self
.
get
(
'https'
)
@https.setter
def
https
(
self
,
value
):
self
[
'https'
]
=
value
@property
@property
def
ftp
(
self
):
def
ftp
(
self
):
return
self
.
get
(
'ftp'
)
return
self
.
get
(
'ftp'
)
@ftp.setter
def
ftp
(
self
,
value
):
self
[
'ftp'
]
=
value
@property
@property
def
no_proxy
(
self
):
def
no_proxy
(
self
):
return
self
.
get
(
'no_proxy'
)
return
self
.
get
(
'no_proxy'
)
@no_proxy.setter
def
no_proxy
(
self
,
value
):
self
[
'no_proxy'
]
=
value
@staticmethod
@staticmethod
def
from_dict
(
config
):
def
from_dict
(
config
):
'''
'''
...
...
tests/integration/api_build_test.py
Dosyayı görüntüle @
65bebc08
...
@@ -16,7 +16,8 @@ from ..helpers import random_name, requires_api_version, requires_experimental
...
@@ -16,7 +16,8 @@ from ..helpers import random_name, requires_api_version, requires_experimental
class
BuildTest
(
BaseAPIIntegrationTest
):
class
BuildTest
(
BaseAPIIntegrationTest
):
def
test_build_with_proxy
(
self
):
def
test_build_with_proxy
(
self
):
self
.
client
.
_proxy_configs
=
ProxyConfig
(
self
.
client
.
_proxy_configs
=
ProxyConfig
(
ftp
=
'a'
,
http
=
'b'
,
https
=
'c'
,
no_proxy
=
'd'
)
ftp
=
'a'
,
http
=
'b'
,
https
=
'c'
,
no_proxy
=
'd'
)
script
=
io
.
BytesIO
(
'
\n
'
.
join
([
script
=
io
.
BytesIO
(
'
\n
'
.
join
([
'FROM busybox'
,
'FROM busybox'
,
...
@@ -29,11 +30,13 @@ class BuildTest(BaseAPIIntegrationTest):
...
@@ -29,11 +30,13 @@ class BuildTest(BaseAPIIntegrationTest):
'RUN env | grep "NO_PROXY=d"'
,
'RUN env | grep "NO_PROXY=d"'
,
'RUN env | grep "no_proxy=d"'
,
'RUN env | grep "no_proxy=d"'
,
])
.
encode
(
'ascii'
))
])
.
encode
(
'ascii'
))
self
.
client
.
build
(
fileobj
=
script
,
decode
=
True
)
self
.
client
.
build
(
fileobj
=
script
,
decode
=
True
)
def
test_build_with_proxy_and_buildargs
(
self
):
def
test_build_with_proxy_and_buildargs
(
self
):
self
.
client
.
_proxy_configs
=
ProxyConfig
(
self
.
client
.
_proxy_configs
=
ProxyConfig
(
ftp
=
'a'
,
http
=
'b'
,
https
=
'c'
,
no_proxy
=
'd'
)
ftp
=
'a'
,
http
=
'b'
,
https
=
'c'
,
no_proxy
=
'd'
)
script
=
io
.
BytesIO
(
'
\n
'
.
join
([
script
=
io
.
BytesIO
(
'
\n
'
.
join
([
'FROM busybox'
,
'FROM busybox'
,
...
@@ -46,10 +49,12 @@ class BuildTest(BaseAPIIntegrationTest):
...
@@ -46,10 +49,12 @@ class BuildTest(BaseAPIIntegrationTest):
'RUN env | grep "NO_PROXY=d"'
,
'RUN env | grep "NO_PROXY=d"'
,
'RUN env | grep "no_proxy=d"'
,
'RUN env | grep "no_proxy=d"'
,
])
.
encode
(
'ascii'
))
])
.
encode
(
'ascii'
))
self
.
client
.
build
(
self
.
client
.
build
(
fileobj
=
script
,
fileobj
=
script
,
decode
=
True
,
decode
=
True
,
buildargs
=
{
'FTP_PROXY'
:
'XXX'
,
'ftp_proxy'
:
'xxx'
})
buildargs
=
{
'FTP_PROXY'
:
'XXX'
,
'ftp_proxy'
:
'xxx'
}
)
def
test_build_streaming
(
self
):
def
test_build_streaming
(
self
):
script
=
io
.
BytesIO
(
'
\n
'
.
join
([
script
=
io
.
BytesIO
(
'
\n
'
.
join
([
...
...
tests/integration/api_exec_test.py
Dosyayı görüntüle @
65bebc08
...
@@ -9,37 +9,42 @@ from ..helpers import (
...
@@ -9,37 +9,42 @@ from ..helpers import (
class
ExecTest
(
BaseAPIIntegrationTest
):
class
ExecTest
(
BaseAPIIntegrationTest
):
def
test_execute_proxy_env
(
self
):
def
test_execute_
command_with_
proxy_env
(
self
):
# Set a custom proxy config on the client
# Set a custom proxy config on the client
self
.
client
.
_proxy_configs
=
ProxyConfig
(
self
.
client
.
_proxy_configs
=
ProxyConfig
(
ftp
=
'a'
,
https
=
'b'
,
http
=
'c'
,
no_proxy
=
'd'
)
ftp
=
'a'
,
https
=
'b'
,
http
=
'c'
,
no_proxy
=
'd'
)
container
=
self
.
client
.
create_container
(
container
=
self
.
client
.
create_container
(
BUSYBOX
,
'cat'
,
detach
=
True
,
stdin_open
=
True
)
BUSYBOX
,
'cat'
,
detach
=
True
,
stdin_open
=
True
,
id
=
container
[
'Id'
]
use_config_proxy
=
True
,
self
.
client
.
start
(
id
)
)
self
.
tmp_containers
.
append
(
id
)
self
.
client
.
start
(
container
)
self
.
tmp_containers
.
append
(
container
)
cmd
=
'sh -c "env | grep -i proxy"'
cmd
=
'sh -c "env | grep -i proxy"'
# First, just make sure the environment variables from the custom
# First, just make sure the environment variables from the custom
# config are set
# config are set
res
=
self
.
client
.
exec_create
(
id
,
cmd
=
cmd
,
use_config_proxy
=
True
)
res
=
self
.
client
.
exec_create
(
container
,
cmd
=
cmd
)
output
=
self
.
client
.
exec_start
(
res
)
.
decode
(
'utf-8'
)
.
split
(
'
\n
'
)
output
=
self
.
client
.
exec_start
(
res
)
.
decode
(
'utf-8'
)
.
split
(
'
\n
'
)
expected
=
[
expected
=
[
'ftp_proxy=a'
,
'https_proxy=b'
,
'http_proxy=c'
,
'no_proxy=d'
,
'ftp_proxy=a'
,
'https_proxy=b'
,
'http_proxy=c'
,
'no_proxy=d'
,
'FTP_PROXY=a'
,
'HTTPS_PROXY=b'
,
'HTTP_PROXY=c'
,
'NO_PROXY=d'
]
'FTP_PROXY=a'
,
'HTTPS_PROXY=b'
,
'HTTP_PROXY=c'
,
'NO_PROXY=d'
]
for
item
in
expected
:
for
item
in
expected
:
assert
item
in
output
assert
item
in
output
# Overwrite some variables with a custom environment
# Overwrite some variables with a custom environment
env
=
{
'https_proxy'
:
'xxx'
,
'HTTPS_PROXY'
:
'XXX'
}
env
=
{
'https_proxy'
:
'xxx'
,
'HTTPS_PROXY'
:
'XXX'
}
res
=
self
.
client
.
exec_create
(
id
,
cmd
=
cmd
,
environment
=
env
,
use_config_proxy
=
True
)
res
=
self
.
client
.
exec_create
(
container
,
cmd
=
cmd
,
environment
=
env
)
output
=
self
.
client
.
exec_start
(
res
)
.
decode
(
'utf-8'
)
.
split
(
'
\n
'
)
output
=
self
.
client
.
exec_start
(
res
)
.
decode
(
'utf-8'
)
.
split
(
'
\n
'
)
expected
=
[
expected
=
[
'ftp_proxy=a'
,
'https_proxy=xxx'
,
'http_proxy=c'
,
'no_proxy=d'
,
'ftp_proxy=a'
,
'https_proxy=xxx'
,
'http_proxy=c'
,
'no_proxy=d'
,
'FTP_PROXY=a'
,
'HTTPS_PROXY=XXX'
,
'HTTP_PROXY=c'
,
'NO_PROXY=d'
]
'FTP_PROXY=a'
,
'HTTPS_PROXY=XXX'
,
'HTTP_PROXY=c'
,
'NO_PROXY=d'
]
for
item
in
expected
:
for
item
in
expected
:
assert
item
in
output
assert
item
in
output
...
...
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