From 7408cf95c0fd54b9df7cd3fd8bfd4286cae12c19 Mon Sep 17 00:00:00 2001 From: jpic Date: Sun, 2 Aug 2020 06:52:39 +0200 Subject: [PATCH] Add Buildah.Env and Buildah.Config --- shlax/targets/buildah.py | 53 +++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/shlax/targets/buildah.py b/shlax/targets/buildah.py index eaf1418..2652386 100644 --- a/shlax/targets/buildah.py +++ b/shlax/targets/buildah.py @@ -16,10 +16,7 @@ class Buildah(Target): """Build container image with buildah""" isguest = True - def __init__(self, - *actions, - base=None, commit=None, - cmd=None): + def __init__(self, *actions, base=None, commit=None): self.base = base or 'alpine' self.image = Image(commit) if commit else None @@ -27,10 +24,6 @@ class Buildah(Target): self.root = None self.mounts = dict() - self.config = dict( - cmd=cmd or 'sh', - ) - # Always consider localhost as parent for now self.parent = Target() @@ -169,9 +162,6 @@ class Buildah(Target): return await self.parent.exec(*_args, **kwargs) async def commit(self): - for key, value in self.config.items(): - await self.parent.exec(f'buildah config --{key} "{value}" {self.ctr}') - await self.parent.exec( f'buildah commit {self.ctr} {self.image.repository}:final' ) @@ -206,3 +196,44 @@ class Buildah(Target): async def copy(self, *args): return await self.parent.copy(*args[:-1], self.path(args[-1])) + + async def write(self, path, content): + return await self.write(path, content) + + async def write(self, path, content, **kwargs): + return await self.exec( + f'cat > {path} <