MCPcopy
hub / github.com/docker/docker-py / ProxyConfig

Class ProxyConfig

docker/utils/proxy.py:4–77  ·  view source on GitHub ↗

Hold the client's proxy configuration

Source from the content-addressed store, hash-verified

2
3
4class ProxyConfig(dict):
5 '''
6 Hold the client's proxy configuration
7 '''
8 @property
9 def http(self):
10 return self.get('http')
11
12 @property
13 def https(self):
14 return self.get('https')
15
16 @property
17 def ftp(self):
18 return self.get('ftp')
19
20 @property
21 def no_proxy(self):
22 return self.get('no_proxy')
23
24 @staticmethod
25 def from_dict(config):
26 '''
27 Instantiate a new ProxyConfig from a dictionary that represents a
28 client configuration, as described in `the documentation`_.
29
30 .. _the documentation:
31 https://docs.docker.com/network/proxy/#configure-the-docker-client
32 '''
33 return ProxyConfig(
34 http=config.get('httpProxy'),
35 https=config.get('httpsProxy'),
36 ftp=config.get('ftpProxy'),
37 no_proxy=config.get('noProxy'),
38 )
39
40 def get_environment(self):
41 '''
42 Return a dictionary representing the environment variables used to
43 set the proxy settings.
44 '''
45 env = {}
46 if self.http:
47 env['http_proxy'] = env['HTTP_PROXY'] = self.http
48 if self.https:
49 env['https_proxy'] = env['HTTPS_PROXY'] = self.https
50 if self.ftp:
51 env['ftp_proxy'] = env['FTP_PROXY'] = self.ftp
52 if self.no_proxy:
53 env['no_proxy'] = env['NO_PROXY'] = self.no_proxy
54 return env
55
56 def inject_proxy_environment(self, environment):
57 '''
58 Given a list of strings representing environment variables, prepend the
59 environment variables corresponding to the proxy settings.
60 '''
61 if not self:

Callers 11

test_build_with_proxyMethod · 0.90
test_newMethod · 0.90
test_truthinessMethod · 0.90
test_environmentMethod · 0.90
test_build_with_proxyMethod · 0.90
from_dictMethod · 0.85

Calls

no outgoing calls