浏览代码

feat: drop empty tag on cache_from

Signed-off-by: Nao YONASHIRO <[email protected]>
Nao YONASHIRO 6 年之前
父节点
当前提交
51ee6093df
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      compose/service.py

+ 7 - 1
compose/service.py

@@ -1078,7 +1078,7 @@ class Service(object):
             pull=pull,
             nocache=no_cache,
             dockerfile=build_opts.get('dockerfile', None),
-            cache_from=build_opts.get('cache_from', None),
+            cache_from=self.get_cache_from(build_opts),
             labels=build_opts.get('labels', None),
             buildargs=build_args,
             network_mode=build_opts.get('network', None),
@@ -1116,6 +1116,12 @@ class Service(object):
 
         return image_id
 
+    def get_cache_from(self, build_opts):
+        cache_from = build_opts.get('cache_from', None)
+        if cache_from is not None:
+            cache_from = [tag for tag in cache_from if tag]
+        return cache_from
+
     def can_be_built(self):
         return 'build' in self.options