mirror of https://github.com/docker/compose.git
Merge pull request #2032 from villlem/master
Flag to skip all pull errors when pulling images
This commit is contained in:
commit
b9252aa48e
|
@ -270,6 +270,7 @@ class TopLevelCommand(Command):
|
|||
Usage: pull [options] [SERVICE...]
|
||||
|
||||
Options:
|
||||
--ignore-pull-failures Pull what it can and ignores images with pull failures.
|
||||
--allow-insecure-ssl Deprecated - no effect.
|
||||
"""
|
||||
if options['--allow-insecure-ssl']:
|
||||
|
@ -277,6 +278,7 @@ class TopLevelCommand(Command):
|
|||
|
||||
project.pull(
|
||||
service_names=options['SERVICE'],
|
||||
ignore_pull_failures=options.get('--ignore-pull-failures')
|
||||
)
|
||||
|
||||
def rm(self, project, options):
|
||||
|
|
|
@ -311,9 +311,9 @@ class Project(object):
|
|||
|
||||
return plans
|
||||
|
||||
def pull(self, service_names=None):
|
||||
def pull(self, service_names=None, ignore_pull_failures=False):
|
||||
for service in self.get_services(service_names, include_deps=True):
|
||||
service.pull()
|
||||
service.pull(ignore_pull_failures)
|
||||
|
||||
def containers(self, service_names=None, stopped=False, one_off=False):
|
||||
if service_names:
|
||||
|
|
|
@ -769,7 +769,7 @@ class Service(object):
|
|||
return True
|
||||
return False
|
||||
|
||||
def pull(self):
|
||||
def pull(self, ignore_pull_failures=False):
|
||||
if 'image' not in self.options:
|
||||
return
|
||||
|
||||
|
@ -781,7 +781,14 @@ class Service(object):
|
|||
tag=tag,
|
||||
stream=True,
|
||||
)
|
||||
stream_output(output, sys.stdout)
|
||||
|
||||
try:
|
||||
stream_output(output, sys.stdout)
|
||||
except StreamOutputError as e:
|
||||
if not ignore_pull_failures:
|
||||
raise
|
||||
else:
|
||||
log.error(six.text_type(e))
|
||||
|
||||
|
||||
class Net(object):
|
||||
|
|
|
@ -212,7 +212,7 @@ _docker_compose_ps() {
|
|||
_docker_compose_pull() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
|
||||
COMPREPLY=( $( compgen -W "--help --ignore-pull-failures" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_services_from_image
|
||||
|
|
|
@ -238,6 +238,7 @@ __docker-compose_subcommand() {
|
|||
(pull)
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'--ignore-pull-failures[Pull what it can and ignores images with pull failures.]' \
|
||||
'*:services:__docker-compose_services_from_image' && ret=0
|
||||
;;
|
||||
(rm)
|
||||
|
|
|
@ -13,6 +13,9 @@ parent = "smn_compose_cli"
|
|||
|
||||
```
|
||||
Usage: pull [options] [SERVICE...]
|
||||
|
||||
Options:
|
||||
--ignore-pull-failures Pull what it can and ignores images with pull failures.
|
||||
```
|
||||
|
||||
Pulls service images.
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
simple:
|
||||
image: busybox:latest
|
||||
command: top
|
||||
another:
|
||||
image: nonexisting-image:latest
|
||||
command: top
|
|
@ -98,6 +98,13 @@ class CLITestCase(DockerClientTestCase):
|
|||
'Pulling digest (busybox@'
|
||||
'sha256:38a203e1986cf79639cfb9b2e1d6e773de84002feea2d4eb006b52004ee8502d)...')
|
||||
|
||||
@mock.patch('compose.service.log')
|
||||
def test_pull_with_ignore_pull_failures(self, mock_logging):
|
||||
self.command.dispatch(['-f', 'ignore-pull-failures.yml', 'pull', '--ignore-pull-failures'], None)
|
||||
mock_logging.info.assert_any_call('Pulling simple (busybox:latest)...')
|
||||
mock_logging.info.assert_any_call('Pulling another (nonexisting-image:latest)...')
|
||||
mock_logging.error.assert_any_call('Error: image library/nonexisting-image:latest not found')
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=StringIO)
|
||||
def test_build_plain(self, mock_stdout):
|
||||
self.command.base_dir = 'tests/fixtures/simple-dockerfile'
|
||||
|
|
Loading…
Reference in New Issue