Skip to content

Commit 65bebc0

Browse files
committed
Style fixes and removed some unused code
Signed-off-by: Joffrey F <[email protected]>
1 parent 6969e8b commit 65bebc0

File tree

4 files changed

+28
-32
lines changed

4 files changed

+28
-32
lines changed

docker/api/container.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,11 @@ def create_container(self, image, command=None, hostname=None, user=None,
410410

411411
if isinstance(environment, dict):
412412
environment = utils.utils.format_environment(environment)
413+
413414
if use_config_proxy:
414-
environment = \
415-
self._proxy_configs.inject_proxy_environment(environment)
415+
environment = self._proxy_configs.inject_proxy_environment(
416+
environment
417+
)
416418

417419
config = self.create_container_config(
418420
image, command, hostname, user, detach, stdin_open, tty,

docker/utils/proxy.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,18 @@ class ProxyConfig(dict):
99
def http(self):
1010
return self.get('http')
1111

12-
@http.setter
13-
def http(self, value):
14-
self['http'] = value
15-
1612
@property
1713
def https(self):
1814
return self.get('https')
1915

20-
@https.setter
21-
def https(self, value):
22-
self['https'] = value
23-
2416
@property
2517
def ftp(self):
2618
return self.get('ftp')
2719

28-
@ftp.setter
29-
def ftp(self, value):
30-
self['ftp'] = value
31-
3220
@property
3321
def no_proxy(self):
3422
return self.get('no_proxy')
3523

36-
@no_proxy.setter
37-
def no_proxy(self, value):
38-
self['no_proxy'] = value
39-
4024
@staticmethod
4125
def from_dict(config):
4226
'''

tests/integration/api_build_test.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
class BuildTest(BaseAPIIntegrationTest):
1717
def test_build_with_proxy(self):
1818
self.client._proxy_configs = ProxyConfig(
19-
ftp='a', http='b', https='c', no_proxy='d')
19+
ftp='a', http='b', https='c', no_proxy='d'
20+
)
2021

2122
script = io.BytesIO('\n'.join([
2223
'FROM busybox',
@@ -29,11 +30,13 @@ def test_build_with_proxy(self):
2930
'RUN env | grep "NO_PROXY=d"',
3031
'RUN env | grep "no_proxy=d"',
3132
]).encode('ascii'))
33+
3234
self.client.build(fileobj=script, decode=True)
3335

3436
def test_build_with_proxy_and_buildargs(self):
3537
self.client._proxy_configs = ProxyConfig(
36-
ftp='a', http='b', https='c', no_proxy='d')
38+
ftp='a', http='b', https='c', no_proxy='d'
39+
)
3740

3841
script = io.BytesIO('\n'.join([
3942
'FROM busybox',
@@ -46,10 +49,12 @@ def test_build_with_proxy_and_buildargs(self):
4649
'RUN env | grep "NO_PROXY=d"',
4750
'RUN env | grep "no_proxy=d"',
4851
]).encode('ascii'))
52+
4953
self.client.build(
5054
fileobj=script,
5155
decode=True,
52-
buildargs={'FTP_PROXY': 'XXX', 'ftp_proxy': 'xxx'})
56+
buildargs={'FTP_PROXY': 'XXX', 'ftp_proxy': 'xxx'}
57+
)
5358

5459
def test_build_streaming(self):
5560
script = io.BytesIO('\n'.join([

tests/integration/api_exec_test.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,42 @@
99

1010

1111
class ExecTest(BaseAPIIntegrationTest):
12-
def test_execute_proxy_env(self):
12+
def test_execute_command_with_proxy_env(self):
1313
# Set a custom proxy config on the client
1414
self.client._proxy_configs = ProxyConfig(
15-
ftp='a', https='b', http='c', no_proxy='d')
15+
ftp='a', https='b', http='c', no_proxy='d'
16+
)
1617

1718
container = self.client.create_container(
18-
BUSYBOX, 'cat', detach=True, stdin_open=True)
19-
id = container['Id']
20-
self.client.start(id)
21-
self.tmp_containers.append(id)
19+
BUSYBOX, 'cat', detach=True, stdin_open=True,
20+
use_config_proxy=True,
21+
)
22+
self.client.start(container)
23+
self.tmp_containers.append(container)
2224

2325
cmd = 'sh -c "env | grep -i proxy"'
2426

2527
# First, just make sure the environment variables from the custom
2628
# config are set
27-
res = self.client.exec_create(id, cmd=cmd, use_config_proxy=True)
29+
30+
res = self.client.exec_create(container, cmd=cmd)
2831
output = self.client.exec_start(res).decode('utf-8').split('\n')
2932
expected = [
3033
'ftp_proxy=a', 'https_proxy=b', 'http_proxy=c', 'no_proxy=d',
31-
'FTP_PROXY=a', 'HTTPS_PROXY=b', 'HTTP_PROXY=c', 'NO_PROXY=d']
34+
'FTP_PROXY=a', 'HTTPS_PROXY=b', 'HTTP_PROXY=c', 'NO_PROXY=d'
35+
]
3236
for item in expected:
3337
assert item in output
3438

3539
# Overwrite some variables with a custom environment
3640
env = {'https_proxy': 'xxx', 'HTTPS_PROXY': 'XXX'}
37-
res = self.client.exec_create(
38-
id, cmd=cmd, environment=env, use_config_proxy=True)
41+
42+
res = self.client.exec_create(container, cmd=cmd, environment=env)
3943
output = self.client.exec_start(res).decode('utf-8').split('\n')
4044
expected = [
4145
'ftp_proxy=a', 'https_proxy=xxx', 'http_proxy=c', 'no_proxy=d',
42-
'FTP_PROXY=a', 'HTTPS_PROXY=XXX', 'HTTP_PROXY=c', 'NO_PROXY=d']
46+
'FTP_PROXY=a', 'HTTPS_PROXY=XXX', 'HTTP_PROXY=c', 'NO_PROXY=d'
47+
]
4348
for item in expected:
4449
assert item in output
4550

0 commit comments

Comments
 (0)