Merge pull request #2032 from villlem/master

Flag to skip all pull errors when pulling images
This commit is contained in:
mnowster 2015-09-21 13:41:08 +01:00
commit b9252aa48e
8 changed files with 31 additions and 5 deletions

View File

@ -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):

View File

@ -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:

View File

@ -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):

View File

@ -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

View File

@ -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)

View File

@ -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.

View File

@ -0,0 +1,6 @@
simple:
image: busybox:latest
command: top
another:
image: nonexisting-image:latest
command: top

View File

@ -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'