From 63e610ca4f6617714525d291b77173ab5a307dc1 Mon Sep 17 00:00:00 2001 From: jpic Date: Thu, 11 Jun 2020 17:37:30 +0200 Subject: [PATCH] Fixing container config support --- shlax/targets/buildah.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/shlax/targets/buildah.py b/shlax/targets/buildah.py index 15a09e7..0073d3c 100644 --- a/shlax/targets/buildah.py +++ b/shlax/targets/buildah.py @@ -144,13 +144,15 @@ class Buildah(Target): for src, dst in self.mounts.items(): await self.parent.exec('umount', self.root / str(dst)[1:]) await self.parent.exec('buildah', 'umount', self.ctr) - await self.parent.exec('buildah', 'rm', self.ctr) if result.status == 'success': await self.commit() if os.getenv('BUILDAH_PUSH'): await self.image.push(target) + if self.ctr is not None: + await self.parent.exec('buildah', 'rm', self.ctr) + async def mount(self, src, dst): """Mount a host directory into the container.""" target = self.root / str(dst)[1:] @@ -166,15 +168,13 @@ class Buildah(Target): _args += [' '.join([str(a) for a in args])] return await self.parent.exec(*_args, **kwargs) - async def commit(self, image=None): - image = image or self.image - if not image: - return + async def commit(self): + for key, value in self.config.items(): + await self.parent.exec(f'buildah config --{key} "{value}" {self.ctr}') - if not image: - # don't go through that if layer commit - 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' + ) ENV_TAGS = ( # gitlab @@ -194,12 +194,12 @@ class Buildah(Target): if value: self.image.tags.append(value) - if image.tags: - tags = [f'{image.repository}:{tag}' for tag in image.tags] + if self.image.tags: + tags = [f'{self.image.repository}:{tag}' for tag in self.image.tags] else: - tags = [image.repository] + tags = [self.image.repository] - await self.parent.exec('buildah', 'tag', self.image_previous, *tags) + await self.parent.exec('buildah', 'tag', self.image.repository + ':final', *tags) async def mkdir(self, *paths): return await self.parent.mkdir(*[self.path(path) for path in paths])