Fixing container config support

This commit is contained in:
jpic 2020-06-11 17:37:30 +02:00
parent 4f5326c81b
commit 63e610ca4f

View File

@ -144,13 +144,15 @@ class Buildah(Target):
for src, dst in self.mounts.items(): for src, dst in self.mounts.items():
await self.parent.exec('umount', self.root / str(dst)[1:]) await self.parent.exec('umount', self.root / str(dst)[1:])
await self.parent.exec('buildah', 'umount', self.ctr) await self.parent.exec('buildah', 'umount', self.ctr)
await self.parent.exec('buildah', 'rm', self.ctr)
if result.status == 'success': if result.status == 'success':
await self.commit() await self.commit()
if os.getenv('BUILDAH_PUSH'): if os.getenv('BUILDAH_PUSH'):
await self.image.push(target) 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): async def mount(self, src, dst):
"""Mount a host directory into the container.""" """Mount a host directory into the container."""
target = self.root / str(dst)[1:] target = self.root / str(dst)[1:]
@ -166,16 +168,14 @@ class Buildah(Target):
_args += [' '.join([str(a) for a in args])] _args += [' '.join([str(a) for a in args])]
return await self.parent.exec(*_args, **kwargs) return await self.parent.exec(*_args, **kwargs)
async def commit(self, image=None): async def commit(self):
image = image or self.image
if not image:
return
if not image:
# don't go through that if layer commit
for key, value in self.config.items(): for key, value in self.config.items():
await self.parent.exec(f'buildah config --{key} "{value}" {self.ctr}') 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 = ( ENV_TAGS = (
# gitlab # gitlab
'CI_COMMIT_SHORT_SHA', 'CI_COMMIT_SHORT_SHA',
@ -194,12 +194,12 @@ class Buildah(Target):
if value: if value:
self.image.tags.append(value) self.image.tags.append(value)
if image.tags: if self.image.tags:
tags = [f'{image.repository}:{tag}' for tag in image.tags] tags = [f'{self.image.repository}:{tag}' for tag in self.image.tags]
else: 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): async def mkdir(self, *paths):
return await self.parent.mkdir(*[self.path(path) for path in paths]) return await self.parent.mkdir(*[self.path(path) for path in paths])