mirror of
https://github.com/docker/compose.git
synced 2025-07-16 10:14:24 +02:00
only pull images that can't build
Signed-off-by: Collins Abitekaniza <abtcolns@gmail.com>
This commit is contained in:
parent
3cddd1b670
commit
c6dd7da15e
@ -602,6 +602,9 @@ class Project(object):
|
|||||||
def pull(self, service_names=None, ignore_pull_failures=False, parallel_pull=False, silent=False,
|
def pull(self, service_names=None, ignore_pull_failures=False, parallel_pull=False, silent=False,
|
||||||
include_deps=False):
|
include_deps=False):
|
||||||
services = self.get_services(service_names, include_deps)
|
services = self.get_services(service_names, include_deps)
|
||||||
|
images_to_build = {service.image_name for service in services if service.can_be_built()}
|
||||||
|
services_to_pull = [service for service in services if service.image_name not in images_to_build]
|
||||||
|
|
||||||
msg = not silent and 'Pulling' or None
|
msg = not silent and 'Pulling' or None
|
||||||
|
|
||||||
if parallel_pull:
|
if parallel_pull:
|
||||||
@ -627,7 +630,7 @@ class Project(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
_, errors = parallel.parallel_execute(
|
_, errors = parallel.parallel_execute(
|
||||||
services,
|
services_to_pull,
|
||||||
pull_service,
|
pull_service,
|
||||||
operator.attrgetter('name'),
|
operator.attrgetter('name'),
|
||||||
msg,
|
msg,
|
||||||
@ -640,7 +643,7 @@ class Project(object):
|
|||||||
raise ProjectError(combined_errors)
|
raise ProjectError(combined_errors)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for service in services:
|
for service in services_to_pull:
|
||||||
service.pull(ignore_pull_failures, silent=silent)
|
service.pull(ignore_pull_failures, silent=silent)
|
||||||
|
|
||||||
def push(self, service_names=None, ignore_push_failures=False):
|
def push(self, service_names=None, ignore_push_failures=False):
|
||||||
|
@ -633,6 +633,13 @@ class CLITestCase(DockerClientTestCase):
|
|||||||
'image library/nonexisting-image:latest not found' in result.stderr or
|
'image library/nonexisting-image:latest not found' in result.stderr or
|
||||||
'pull access denied for nonexisting-image' in result.stderr)
|
'pull access denied for nonexisting-image' in result.stderr)
|
||||||
|
|
||||||
|
def test_pull_with_build(self):
|
||||||
|
result = self.dispatch(['-f', 'pull-with-build.yml', 'pull'])
|
||||||
|
|
||||||
|
assert 'Pulling simple' not in result.stderr
|
||||||
|
assert 'Pulling from_simple' not in result.stderr
|
||||||
|
assert 'Pulling another ...' in result.stderr
|
||||||
|
|
||||||
def test_pull_with_quiet(self):
|
def test_pull_with_quiet(self):
|
||||||
assert self.dispatch(['pull', '--quiet']).stderr == ''
|
assert self.dispatch(['pull', '--quiet']).stderr == ''
|
||||||
assert self.dispatch(['pull', '--quiet']).stdout == ''
|
assert self.dispatch(['pull', '--quiet']).stdout == ''
|
||||||
|
11
tests/fixtures/simple-composefile/pull-with-build.yml
vendored
Normal file
11
tests/fixtures/simple-composefile/pull-with-build.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
build_simple:
|
||||||
|
image: simple
|
||||||
|
build: .
|
||||||
|
command: top
|
||||||
|
from_simple:
|
||||||
|
image: simple
|
||||||
|
another:
|
||||||
|
image: busybox:latest
|
||||||
|
command: top
|
Loading…
x
Reference in New Issue
Block a user