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
bfdd0a88
Kaydet (Commit)
bfdd0a88
authored
Ara 12, 2018
tarafından
Corentin Henry
Kaydeden (comit)
Joffrey F
Ock 09, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
add support for proxies
Signed-off-by:
Corentin Henry
<
corentinhenry@gmail.com
>
üst
4ca4e94e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
1 deletion
+85
-1
build.py
docker/api/build.py
+4
-1
client.py
docker/api/client.py
+7
-0
container.py
docker/api/container.py
+4
-0
exec_api.py
docker/api/exec_api.py
+1
-0
proxy.py
docker/utils/proxy.py
+69
-0
No files found.
docker/api/build.py
Dosyayı görüntüle @
bfdd0a88
...
...
@@ -168,8 +168,11 @@ class BuildApiMixin(object):
}
params
.
update
(
container_limits
)
final_buildargs
=
self
.
_proxy_configs
.
get_environment
()
if
buildargs
:
params
.
update
({
'buildargs'
:
json
.
dumps
(
buildargs
)})
final_buildargs
.
update
(
buildargs
)
if
final_buildargs
:
params
.
update
({
'buildargs'
:
json
.
dumps
(
final_buildargs
)})
if
shmsize
:
if
utils
.
version_gte
(
self
.
_version
,
'1.22'
):
...
...
docker/api/client.py
Dosyayı görüntüle @
bfdd0a88
...
...
@@ -34,6 +34,7 @@ from ..transport import SSLAdapter, UnixAdapter
from
..utils
import
utils
,
check_resource
,
update_headers
,
config
from
..utils.socket
import
frames_iter
,
consume_socket_output
,
demux_adaptor
from
..utils.json_stream
import
json_stream
from
..utils.proxy
import
ProxyConfig
try
:
from
..transport
import
NpipeAdapter
except
ImportError
:
...
...
@@ -114,6 +115,12 @@ class APIClient(
self
.
headers
[
'User-Agent'
]
=
user_agent
self
.
_general_configs
=
config
.
load_general_config
()
try
:
proxies
=
self
.
_general_configs
[
'proxies'
][
'default'
]
except
KeyError
:
proxies
=
{}
self
.
_proxy_configs
=
ProxyConfig
.
from_dict
(
proxies
)
self
.
_auth_configs
=
auth
.
load_config
(
config_dict
=
self
.
_general_configs
,
credstore_env
=
credstore_env
,
)
...
...
docker/api/container.py
Dosyayı görüntüle @
bfdd0a88
...
...
@@ -403,6 +403,10 @@ class ContainerApiMixin(object):
if
isinstance
(
volumes
,
six
.
string_types
):
volumes
=
[
volumes
,
]
if
isinstance
(
environment
,
dict
):
environment
=
utils
.
utils
.
format_environment
(
environment
)
environment
=
self
.
_proxy_configs
.
inject_proxy_environment
(
environment
)
config
=
self
.
create_container_config
(
image
,
command
,
hostname
,
user
,
detach
,
stdin_open
,
tty
,
ports
,
environment
,
volumes
,
...
...
docker/api/exec_api.py
Dosyayı görüntüle @
bfdd0a88
...
...
@@ -50,6 +50,7 @@ class ExecApiMixin(object):
if
isinstance
(
environment
,
dict
):
environment
=
utils
.
utils
.
format_environment
(
environment
)
environment
=
self
.
_proxy_configs
.
inject_proxy_environment
(
environment
)
data
=
{
'Container'
:
container
,
...
...
docker/utils/proxy.py
0 → 100644
Dosyayı görüntüle @
bfdd0a88
from
.utils
import
format_environment
class
ProxyConfig
():
'''
Hold the client's proxy configuration
'''
def
__init__
(
self
,
http
=
None
,
https
=
None
,
ftp
=
None
,
no_proxy
=
None
):
self
.
http
=
http
self
.
https
=
https
self
.
ftp
=
ftp
self
.
no_proxy
=
no_proxy
@staticmethod
def
from_dict
(
config
):
'''
Instantiate a new ProxyConfig from a dictionary that represents a
client configuration, as described in `the documentation`_.
.. _the documentation:
https://docs.docker.com/network/proxy/#configure-the-docker-client
'''
return
ProxyConfig
(
http
=
config
.
get
(
'httpProxy'
,
None
),
https
=
config
.
get
(
'httpsProxy'
,
None
),
ftp
=
config
.
get
(
'ftpProxy'
,
None
),
no_proxy
=
config
.
get
(
'noProxy'
,
None
))
def
get_environment
(
self
):
'''
Return a dictionary representing the environment variables used to
set the proxy settings.
'''
env
=
{}
if
self
.
http
:
env
[
'http_proxy'
]
=
env
[
'HTTP_PROXY'
]
=
self
.
http
if
self
.
https
:
env
[
'https_proxy'
]
=
env
[
'HTTPS_PROXY'
]
=
self
.
https
if
self
.
ftp
:
env
[
'ftp_proxy'
]
=
env
[
'FTP_PROXY'
]
=
self
.
ftp
if
self
.
no_proxy
:
env
[
'no_proxy'
]
=
env
[
'NO_PROXY'
]
=
self
.
no_proxy
return
env
def
inject_proxy_environment
(
self
,
environment
):
'''
Given a list of strings representing environment variables, prepend the
environemt variables corresponding to the proxy settings.
'''
if
not
self
:
return
environment
proxy_env
=
format_environment
(
self
.
get_environment
())
if
not
environment
:
return
proxy_env
# It is important to prepend our variables, because we want the
# variables defined in "environment" to take precedence.
return
proxy_env
+
environment
def
__bool__
(
self
):
return
bool
(
self
.
http
or
self
.
https
or
self
.
ftp
or
self
.
no_proxy
)
def
__nonzero__
(
self
):
return
self
.
__bool__
()
def
__str__
(
self
):
return
'ProxyConfig(http={}, https={}, ftp={}, no_proxy={})'
.
format
(
self
.
http
,
self
.
https
,
self
.
ftp
,
self
.
no_proxy
)
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