Skip to content

Commit 04a773f

Browse files
committed
Deprecate --allow-insecure-ssl
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
1 parent f4dac02 commit 04a773f

File tree

10 files changed

+26
-64
lines changed

10 files changed

+26
-64
lines changed

compose/cli/main.py

+16-13
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626

2727
log = logging.getLogger(__name__)
2828

29+
INSECURE_SSL_WARNING = """
30+
Warning: --allow-insecure-ssl is deprecated and has no effect.
31+
It will be removed in a future version of Compose.
32+
"""
33+
2934

3035
def main():
3136
setup_logging()
@@ -232,13 +237,13 @@ def pull(self, project, options):
232237
Usage: pull [options] [SERVICE...]
233238
234239
Options:
235-
--allow-insecure-ssl Allow insecure connections to the docker
236-
registry
240+
--allow-insecure-ssl Deprecated - no effect.
237241
"""
238-
insecure_registry = options['--allow-insecure-ssl']
242+
if options['--allow-insecure-ssl']:
243+
log.warn(INSECURE_SSL_WARNING)
244+
239245
project.pull(
240246
service_names=options['SERVICE'],
241-
insecure_registry=insecure_registry
242247
)
243248

244249
def rm(self, project, options):
@@ -280,8 +285,7 @@ def run(self, project, options):
280285
Usage: run [options] [-e KEY=VAL...] SERVICE [COMMAND] [ARGS...]
281286
282287
Options:
283-
--allow-insecure-ssl Allow insecure connections to the docker
284-
registry
288+
--allow-insecure-ssl Deprecated - no effect.
285289
-d Detached mode: Run container in the background, print
286290
new container name.
287291
--entrypoint CMD Override the entrypoint of the image.
@@ -296,7 +300,8 @@ def run(self, project, options):
296300
"""
297301
service = project.get_service(options['SERVICE'])
298302

299-
insecure_registry = options['--allow-insecure-ssl']
303+
if options['--allow-insecure-ssl']:
304+
log.warn(INSECURE_SSL_WARNING)
300305

301306
if not options['--no-deps']:
302307
deps = service.get_linked_names()
@@ -306,7 +311,6 @@ def run(self, project, options):
306311
service_names=deps,
307312
start_deps=True,
308313
allow_recreate=False,
309-
insecure_registry=insecure_registry,
310314
)
311315

312316
tty = True
@@ -344,7 +348,6 @@ def run(self, project, options):
344348
container = service.create_container(
345349
quiet=True,
346350
one_off=True,
347-
insecure_registry=insecure_registry,
348351
**container_options
349352
)
350353
except APIError as e:
@@ -453,8 +456,7 @@ def up(self, project, options):
453456
Usage: up [options] [SERVICE...]
454457
455458
Options:
456-
--allow-insecure-ssl Allow insecure connections to the docker
457-
registry
459+
--allow-insecure-ssl Deprecated - no effect.
458460
-d Detached mode: Run containers in the background,
459461
print new container names.
460462
--no-color Produce monochrome output.
@@ -468,7 +470,9 @@ def up(self, project, options):
468470
when attached or when containers are already
469471
running. (default: 10)
470472
"""
471-
insecure_registry = options['--allow-insecure-ssl']
473+
if options['--allow-insecure-ssl']:
474+
log.warn(INSECURE_SSL_WARNING)
475+
472476
detached = options['-d']
473477

474478
monochrome = options['--no-color']
@@ -487,7 +491,6 @@ def up(self, project, options):
487491
start_deps=start_deps,
488492
allow_recreate=allow_recreate,
489493
force_recreate=force_recreate,
490-
insecure_registry=insecure_registry,
491494
do_build=not options['--no-build'],
492495
timeout=timeout
493496
)

compose/project.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ def up(self,
239239
start_deps=True,
240240
allow_recreate=True,
241241
force_recreate=False,
242-
insecure_registry=False,
243242
do_build=True,
244243
timeout=DEFAULT_TIMEOUT):
245244

@@ -262,7 +261,6 @@ def up(self,
262261
for service in services
263262
for container in service.execute_convergence_plan(
264263
plans[service.name],
265-
insecure_registry=insecure_registry,
266264
do_build=do_build,
267265
timeout=timeout
268266
)
@@ -302,9 +300,9 @@ def _get_convergence_plans(self,
302300

303301
return plans
304302

305-
def pull(self, service_names=None, insecure_registry=False):
303+
def pull(self, service_names=None):
306304
for service in self.get_services(service_names, include_deps=True):
307-
service.pull(insecure_registry=insecure_registry)
305+
service.pull()
308306

309307
def containers(self, service_names=None, stopped=False, one_off=False):
310308
if service_names:

compose/service.py

+4-12
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ def remove_stopped(self, **options):
247247

248248
def create_container(self,
249249
one_off=False,
250-
insecure_registry=False,
251250
do_build=True,
252251
previous_container=None,
253252
number=None,
@@ -259,7 +258,6 @@ def create_container(self,
259258
"""
260259
self.ensure_image_exists(
261260
do_build=do_build,
262-
insecure_registry=insecure_registry,
263261
)
264262

265263
container_options = self._get_container_create_options(
@@ -275,8 +273,7 @@ def create_container(self,
275273
return Container.create(self.client, **container_options)
276274

277275
def ensure_image_exists(self,
278-
do_build=True,
279-
insecure_registry=False):
276+
do_build=True):
280277

281278
try:
282279
self.image()
@@ -290,7 +287,7 @@ def ensure_image_exists(self,
290287
else:
291288
raise NeedsBuildError(self)
292289
else:
293-
self.pull(insecure_registry=insecure_registry)
290+
self.pull()
294291

295292
def image(self):
296293
try:
@@ -360,14 +357,12 @@ def _containers_have_diverged(self, containers):
360357

361358
def execute_convergence_plan(self,
362359
plan,
363-
insecure_registry=False,
364360
do_build=True,
365361
timeout=DEFAULT_TIMEOUT):
366362
(action, containers) = plan
367363

368364
if action == 'create':
369365
container = self.create_container(
370-
insecure_registry=insecure_registry,
371366
do_build=do_build,
372367
)
373368
self.start_container(container)
@@ -378,7 +373,6 @@ def execute_convergence_plan(self,
378373
return [
379374
self.recreate_container(
380375
c,
381-
insecure_registry=insecure_registry,
382376
timeout=timeout
383377
)
384378
for c in containers
@@ -401,7 +395,6 @@ def execute_convergence_plan(self,
401395

402396
def recreate_container(self,
403397
container,
404-
insecure_registry=False,
405398
timeout=DEFAULT_TIMEOUT):
406399
"""Recreate a container.
407400
@@ -426,7 +419,6 @@ def recreate_container(self,
426419
'%s_%s' % (container.short_id, container.name))
427420

428421
new_container = self.create_container(
429-
insecure_registry=insecure_registry,
430422
do_build=False,
431423
previous_container=container,
432424
number=container.labels.get(LABEL_CONTAINER_NUMBER),
@@ -761,7 +753,7 @@ def specifies_host_port(self):
761753
return True
762754
return False
763755

764-
def pull(self, insecure_registry=False):
756+
def pull(self):
765757
if 'image' not in self.options:
766758
return
767759

@@ -772,7 +764,7 @@ def pull(self, insecure_registry=False):
772764
repo,
773765
tag=tag,
774766
stream=True,
775-
insecure_registry=insecure_registry)
767+
)
776768
stream_output(output, sys.stdout)
777769

778770

contrib/completion/bash/docker-compose

+3-3
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ _docker-compose_ps() {
195195
_docker-compose_pull() {
196196
case "$cur" in
197197
-*)
198-
COMPREPLY=( $( compgen -W "--allow-insecure-ssl --help" -- "$cur" ) )
198+
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
199199
;;
200200
*)
201201
__docker-compose_services_from_image
@@ -248,7 +248,7 @@ _docker-compose_run() {
248248

249249
case "$cur" in
250250
-*)
251-
COMPREPLY=( $( compgen -W "--allow-insecure-ssl -d --entrypoint -e --help --no-deps --rm --service-ports -T --user -u" -- "$cur" ) )
251+
COMPREPLY=( $( compgen -W "-d --entrypoint -e --help --no-deps --rm --service-ports -T --user -u" -- "$cur" ) )
252252
;;
253253
*)
254254
__docker-compose_services_all
@@ -315,7 +315,7 @@ _docker-compose_up() {
315315

316316
case "$cur" in
317317
-*)
318-
COMPREPLY=( $( compgen -W "--allow-insecure-ssl -d --help --no-build --no-color --no-deps --no-recreate --force-recreate --timeout -t" -- "$cur" ) )
318+
COMPREPLY=( $( compgen -W "-d --help --no-build --no-color --no-deps --no-recreate --force-recreate --timeout -t" -- "$cur" ) )
319319
;;
320320
*)
321321
__docker-compose_services_all

contrib/completion/zsh/_docker-compose

-3
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ __docker-compose_subcommand () {
202202
;;
203203
(pull)
204204
_arguments \
205-
'--allow-insecure-ssl[Allow insecure connections to the docker registry]' \
206205
'--help[Print usage]' \
207206
'*:services:__docker-compose_services_from_image' && ret=0
208207
;;
@@ -215,7 +214,6 @@ __docker-compose_subcommand () {
215214
;;
216215
(run)
217216
_arguments \
218-
'--allow-insecure-ssl[Allow insecure connections to the docker registry]' \
219217
'-d[Detached mode: Run container in the background, print new container name.]' \
220218
'--entrypoint[Overwrite the entrypoint of the image.]:entry point: ' \
221219
'*-e[KEY=VAL Set an environment variable (can be used multiple times)]:environment variable KEY=VAL: ' \
@@ -247,7 +245,6 @@ __docker-compose_subcommand () {
247245
;;
248246
(up)
249247
_arguments \
250-
'--allow-insecure-ssl[Allow insecure connections to the docker registry]' \
251248
'-d[Detached mode: Run containers in the background, print new container names.]' \
252249
'--help[Print usage]' \
253250
'--no-color[Produce monochrome output.]' \

docs/reference/pull.md

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ parent = "smn_compose_cli"
1212

1313
```
1414
Usage: pull [options] [SERVICE...]
15-
16-
Options:
17-
--allow-insecure-ssl Allow insecure connections to the docker registry
1815
```
1916

2017
Pulls service images.

docs/reference/run.md

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ parent = "smn_compose_cli"
1414
Usage: run [options] [-e KEY=VAL...] SERVICE [COMMAND] [ARGS...]
1515
1616
Options:
17-
--allow-insecure-ssl Allow insecure connections to the docker
18-
registry
1917
-d Detached mode: Run container in the background, print
2018
new container name.
2119
--entrypoint CMD Override the entrypoint of the image.

docs/reference/up.md

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ parent = "smn_compose_cli"
1414
Usage: up [options] [SERVICE...]
1515
1616
Options:
17-
--allow-insecure-ssl Allow insecure connections to the docker
18-
registry
1917
-d Detached mode: Run containers in the background,
2018
print new container names.
2119
--no-color Produce monochrome output.

tests/integration/state_test.py

-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ def test_change_root_no_recreate(self):
155155
def converge(service,
156156
allow_recreate=True,
157157
force_recreate=False,
158-
insecure_registry=False,
159158
do_build=True):
160159
"""
161160
If a container for this service doesn't exist, create and start one. If there are
@@ -168,7 +167,6 @@ def converge(service,
168167

169168
return service.execute_convergence_plan(
170169
plan,
171-
insecure_registry=insecure_registry,
172170
do_build=do_build,
173171
timeout=1,
174172
)

tests/unit/service_test.py

+1-20
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,10 @@ def test_get_container(self, mock_container_class):
229229
@mock.patch('compose.service.log', autospec=True)
230230
def test_pull_image(self, mock_log):
231231
service = Service('foo', client=self.mock_client, image='someimage:sometag')
232-
service.pull(insecure_registry=True)
232+
service.pull()
233233
self.mock_client.pull.assert_called_once_with(
234234
'someimage',
235235
tag='sometag',
236-
insecure_registry=True,
237236
stream=True)
238237
mock_log.info.assert_called_once_with('Pulling foo (someimage:sometag)...')
239238

@@ -243,26 +242,8 @@ def test_pull_image_no_tag(self):
243242
self.mock_client.pull.assert_called_once_with(
244243
'ababab',
245244
tag='latest',
246-
insecure_registry=False,
247245
stream=True)
248246

249-
def test_create_container_from_insecure_registry(self):
250-
service = Service('foo', client=self.mock_client, image='someimage:sometag')
251-
images = []
252-
253-
def pull(repo, tag=None, insecure_registry=False, **kwargs):
254-
self.assertEqual('someimage', repo)
255-
self.assertEqual('sometag', tag)
256-
self.assertTrue(insecure_registry)
257-
images.append({'Id': 'abc123'})
258-
return []
259-
260-
service.image = lambda *args, **kwargs: mock_get_image(images)
261-
self.mock_client.pull = pull
262-
263-
service.create_container(insecure_registry=True)
264-
self.assertEqual(1, len(images))
265-
266247
@mock.patch('compose.service.Container', autospec=True)
267248
def test_recreate_container(self, _):
268249
mock_container = mock.create_autospec(Container)

0 commit comments

Comments
 (0)