Skip to content

Commit

Permalink
Fix cache_from spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
avirshup committed Nov 3, 2017
1 parent bc4482e commit 7745210
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions dockermake/imagedefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ def generate_build(self, image, targetname, rebuilds=None, cache_repo='', cache_
"""
from_image = self.get_external_base_image(image)
if cache_repo or cache_tag:
from_cache = utils.generate_name(image, cache_repo, cache_tag)
cache_from = utils.generate_name(image, cache_repo, cache_tag)
else:
from_cache = None
cache_from = None
if from_image is None:
raise errors.NoBaseError("No base image found in %s's dependencies" % image)
if isinstance(from_image, ExternalDockerfile):
Expand All @@ -161,7 +161,7 @@ def generate_build(self, image, targetname, rebuilds=None, cache_repo='', cache_
dockermake.step.BuildStep(
base_name, base_image, self.ymldefs[base_name],
buildname, bust_cache=base_name in rebuilds,
build_first=build_first, from_cache=from_cache))
build_first=build_first, cache_from=cache_from))

base_image = buildname
build_first = None
Expand All @@ -176,7 +176,7 @@ def generate_build(self, image, targetname, rebuilds=None, cache_repo='', cache_
sourceimage, sourcepath, destpath,
base_name, base_image, self.ymldefs[base_name],
buildname, bust_cache=base_name in rebuilds,
build_first=build_first, from_cache=from_cache))
build_first=build_first, cache_from=cache_from))
base_image = buildname

sourcebuilds = [self.generate_build(img, img, cache_repo=cache_repo, cache_tag=cache_tag)
Expand Down
10 changes: 5 additions & 5 deletions dockermake/staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ class StagedFile(object):
sourceimage (str): name of the image to copy from
sourcepath (str): path in the source image
destpath (str): path in the target image
from_cache (str or list): use this(these) image(s) to resolve build cache
cache_from (str or list): use this(these) image(s) to resolve build cache
"""
def __init__(self, sourceimage, sourcepath, destpath, from_cache=None):
def __init__(self, sourceimage, sourcepath, destpath, cache_from=None):
self.sourceimage = sourceimage
self.sourcepath = sourcepath
self.destpath = destpath
self._sourceobj = None
self._cachedir = None
self.from_cache = from_cache
self.cache_from = cache_from

def stage(self, startimage, newimage):
""" Copies the file from source to target
Expand Down Expand Up @@ -106,8 +106,8 @@ def stage(self, startimage, newimage):
tag=newimage,
decode=True)

if self.from_cache:
buildargs['from_cache'] = self.from_cache
if self.cache_from:
buildargs['cache_from'] = self.cache_from

# Build and show logs
stream = client.api.build(**buildargs)
Expand Down
18 changes: 9 additions & 9 deletions dockermake/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class BuildStep(object):
img_def (dict): yaml definition of this image
buildname (str): what to call this image, once built
bust_cache(bool): never use docker cache for this build step
from_cache (str or list): use this(these) image(s) to resolve build cache
cache_from (str or list): use this(these) image(s) to resolve build cache
"""

def __init__(self, imagename, baseimage, img_def, buildname,
build_first=None, bust_cache=False, from_cache=None):
build_first=None, bust_cache=False, cache_from=None):
self.imagename = imagename
self.baseimage = baseimage
self.img_def = img_def
Expand All @@ -50,10 +50,10 @@ def __init__(self, imagename, baseimage, img_def, buildname,
self.build_first = build_first
self.custom_exclude = self._get_ignorefile(img_def)
self.ignoredefs_file = img_def.get('ignorefile', img_def['_sourcefile'])
if from_cache and isinstance(str, from_cache):
self.from_cache = [from_cache]
if cache_from and isinstance(cache_from, str):
self.cache_from = [cache_from]
else:
self.from_cache = from_cache
self.cache_from = cache_from

@staticmethod
def _get_ignorefile(img_def):
Expand Down Expand Up @@ -103,8 +103,8 @@ def build(self, client, pull=False, usecache=True):
nocache=not usecache,
decode=True, rm=True)

if usecache and self.from_cache:
build_args['from_cache'] = self.from_cache
if usecache and self.cache_from:
build_args['cache_from'] = self.cache_from

if self.build_dir is not None:
tempdir = self.write_dockerfile(dockerfile)
Expand Down Expand Up @@ -198,7 +198,7 @@ class FileCopyStep(BuildStep):
baseimage (str): base image for this step
img_def (dict): yaml definition of this image
buildname (str): what to call this image, once built
from_cache (str or list): use this(these) image(s) to resolve build cache
cache_from (str or list): use this(these) image(s) to resolve build cache
"""
def __init__(self, sourceimage, sourcepath, destpath, *args, **kwargs):
kwargs.pop('bust_cache', None)
Expand All @@ -214,7 +214,7 @@ def build(self, client, pull=False, usecache=True):
hey were applied when BUILDING self.sourceimage
"""
stage = staging.StagedFile(self.sourceimage, self.sourcepath, self.destpath,
from_cache=self.from_cache)
cache_from=self.cache_from)
stage.stage(self.baseimage, self.buildname)

@property
Expand Down

0 comments on commit 7745210

Please sign in to comment.