mirror of
https://github.com/docker/compose.git
synced 2025-06-04 22:00:12 +02:00
Flag to skip all pull errors when pulling images.
Signed-off-by: Vojta Orgon <villlem@gmail.com>
This commit is contained in:
parent
bbc8b74c17
commit
c9083e21c8
@ -270,6 +270,7 @@ class TopLevelCommand(Command):
|
|||||||
Usage: pull [options] [SERVICE...]
|
Usage: pull [options] [SERVICE...]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
--ignore-pull-failures Pull what it can and ignores images with pull failures.
|
||||||
--allow-insecure-ssl Deprecated - no effect.
|
--allow-insecure-ssl Deprecated - no effect.
|
||||||
"""
|
"""
|
||||||
if options['--allow-insecure-ssl']:
|
if options['--allow-insecure-ssl']:
|
||||||
@ -277,6 +278,7 @@ class TopLevelCommand(Command):
|
|||||||
|
|
||||||
project.pull(
|
project.pull(
|
||||||
service_names=options['SERVICE'],
|
service_names=options['SERVICE'],
|
||||||
|
ignore_pull_failures=options.get('--ignore-pull-failures')
|
||||||
)
|
)
|
||||||
|
|
||||||
def rm(self, project, options):
|
def rm(self, project, options):
|
||||||
|
@ -311,9 +311,9 @@ class Project(object):
|
|||||||
|
|
||||||
return plans
|
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):
|
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):
|
def containers(self, service_names=None, stopped=False, one_off=False):
|
||||||
if service_names:
|
if service_names:
|
||||||
|
@ -769,7 +769,7 @@ class Service(object):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def pull(self):
|
def pull(self, ignore_pull_failures=False):
|
||||||
if 'image' not in self.options:
|
if 'image' not in self.options:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -781,7 +781,14 @@ class Service(object):
|
|||||||
tag=tag,
|
tag=tag,
|
||||||
stream=True,
|
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):
|
class Net(object):
|
||||||
|
@ -212,7 +212,7 @@ _docker_compose_ps() {
|
|||||||
_docker_compose_pull() {
|
_docker_compose_pull() {
|
||||||
case "$cur" in
|
case "$cur" in
|
||||||
-*)
|
-*)
|
||||||
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "--help --ignore-pull-failures" -- "$cur" ) )
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
__docker_compose_services_from_image
|
__docker_compose_services_from_image
|
||||||
|
@ -237,6 +237,7 @@ __docker-compose_subcommand() {
|
|||||||
(pull)
|
(pull)
|
||||||
_arguments \
|
_arguments \
|
||||||
$opts_help \
|
$opts_help \
|
||||||
|
'--ignore-pull-failures[Pull what it can and ignores images with pull failures.]' \
|
||||||
'*:services:__docker-compose_services_from_image' && ret=0
|
'*:services:__docker-compose_services_from_image' && ret=0
|
||||||
;;
|
;;
|
||||||
(rm)
|
(rm)
|
||||||
|
@ -13,6 +13,9 @@ parent = "smn_compose_cli"
|
|||||||
|
|
||||||
```
|
```
|
||||||
Usage: pull [options] [SERVICE...]
|
Usage: pull [options] [SERVICE...]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--ignore-pull-failures Pull what it can and ignores images with pull failures.
|
||||||
```
|
```
|
||||||
|
|
||||||
Pulls service images.
|
Pulls service images.
|
||||||
|
6
tests/fixtures/simple-composefile/ignore-pull-failures.yml
vendored
Normal file
6
tests/fixtures/simple-composefile/ignore-pull-failures.yml
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
simple:
|
||||||
|
image: busybox:latest
|
||||||
|
command: top
|
||||||
|
another:
|
||||||
|
image: nonexisting-image:latest
|
||||||
|
command: top
|
@ -97,6 +97,13 @@ class CLITestCase(DockerClientTestCase):
|
|||||||
'Pulling digest (busybox@'
|
'Pulling digest (busybox@'
|
||||||
'sha256:38a203e1986cf79639cfb9b2e1d6e773de84002feea2d4eb006b52004ee8502d)...')
|
'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)
|
@mock.patch('sys.stdout', new_callable=StringIO)
|
||||||
def test_build_plain(self, mock_stdout):
|
def test_build_plain(self, mock_stdout):
|
||||||
self.command.base_dir = 'tests/fixtures/simple-dockerfile'
|
self.command.base_dir = 'tests/fixtures/simple-dockerfile'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user