Improve Buildah clean method
This commit is contained in:
parent
f5c7e0b1a1
commit
9c3790e438
@ -126,7 +126,8 @@ class Buildah(Target):
|
|||||||
return self.image.layer(sha1.hexdigest())
|
return self.image.layer(sha1.hexdigest())
|
||||||
|
|
||||||
async def action(self, action, reraise=False):
|
async def action(self, action, reraise=False):
|
||||||
result = await super().action(action, reraise)
|
stop = await super().action(action, reraise)
|
||||||
|
if not stop:
|
||||||
action_image = await self.action_image(action)
|
action_image = await self.action_image(action)
|
||||||
await self.parent.exec(
|
await self.parent.exec(
|
||||||
'buildah',
|
'buildah',
|
||||||
@ -136,23 +137,22 @@ class Buildah(Target):
|
|||||||
action_image,
|
action_image,
|
||||||
)
|
)
|
||||||
self.image_previous = action_image
|
self.image_previous = action_image
|
||||||
return result
|
return stop
|
||||||
|
|
||||||
async def clean(self, target):
|
async def clean(self, 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:])
|
||||||
|
|
||||||
if self.result.status == 'success':
|
|
||||||
await self.commit()
|
|
||||||
|
|
||||||
if self.root is not None:
|
if self.root is not None:
|
||||||
await self.parent.exec('buildah', 'umount', self.ctr)
|
await self.parent.exec('buildah', 'umount', self.ctr)
|
||||||
|
|
||||||
if self.ctr is not None:
|
if self.ctr is not None:
|
||||||
|
if self.result.status == 'success':
|
||||||
|
await self.commit()
|
||||||
|
|
||||||
await self.parent.exec('buildah', 'rm', self.ctr)
|
await self.parent.exec('buildah', 'rm', self.ctr)
|
||||||
|
|
||||||
if self.result.status == 'success':
|
if self.result.status == 'success' and os.getenv('BUILDAH_PUSH'):
|
||||||
if os.getenv('BUILDAH_PUSH'):
|
|
||||||
await self.image.push(target)
|
await self.image.push(target)
|
||||||
|
|
||||||
async def mount(self, src, dst):
|
async def mount(self, src, dst):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user