From e496c641273326c7314e01f434313a56f48ba7b0 Mon Sep 17 00:00:00 2001 From: Ulysses Souza Date: Thu, 1 Apr 2021 03:16:05 -0300 Subject: Add Snyk scan suggestion when building Signed-off-by: Ulysses Souza --- compose/service.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'compose/service.py') diff --git a/compose/service.py b/compose/service.py index 716a7557..fda1edb2 100644 --- a/compose/service.py +++ b/compose/service.py @@ -366,6 +366,24 @@ class Service: "rebuild this image you must use `docker-compose build` or " "`docker-compose up --build`.".format(self.name)) + def must_build(self, do_build=BuildAction.none): + if self.can_be_built() and do_build == BuildAction.force: + return True + + try: + self.image() + return False + except NoSuchImageError: + pass + + if not self.can_be_built(): + return False + + if do_build == BuildAction.skip: + return False + + return True + def get_image_registry_data(self): try: return self.client.inspect_distribution(self.image_name) -- cgit v1.2.3