Tag/build/push refactor
This commit is contained in:
parent
8dd4fa52ac
commit
0929b37b36
@ -63,22 +63,17 @@ class Buildah(Target):
|
|||||||
if actions:
|
if actions:
|
||||||
actions = actions[len(keep):]
|
actions = actions[len(keep):]
|
||||||
if not actions:
|
if not actions:
|
||||||
return self.uptodate()
|
return self.output.success('Image up to date')
|
||||||
else:
|
else:
|
||||||
self.actions = self.actions[len(keep):]
|
self.actions = self.actions[len(keep):]
|
||||||
if not self.actions:
|
if not self.actions:
|
||||||
return self.uptodate()
|
return self.output.success('Image up to date')
|
||||||
|
|
||||||
self.ctr = (await self.parent.exec('buildah', 'from', self.base)).out
|
self.ctr = (await self.parent.exec('buildah', 'from', self.base)).out
|
||||||
self.root = Path((await self.parent.exec('buildah', 'mount', self.ctr)).out)
|
self.root = Path((await self.parent.exec('buildah', 'mount', self.ctr)).out)
|
||||||
|
|
||||||
return await super().__call__(*actions)
|
return await super().__call__(*actions)
|
||||||
|
|
||||||
def uptodate(self):
|
|
||||||
self.clean = None
|
|
||||||
self.output.success('Image up to date')
|
|
||||||
return
|
|
||||||
|
|
||||||
async def layers(self):
|
async def layers(self):
|
||||||
ret = set()
|
ret = set()
|
||||||
results = await self.parent.exec(
|
results = await self.parent.exec(
|
||||||
@ -144,19 +139,15 @@ class Buildah(Target):
|
|||||||
return stop
|
return stop
|
||||||
|
|
||||||
async def clean(self, target, result):
|
async def clean(self, target, result):
|
||||||
for src, dst in self.mounts.items():
|
|
||||||
await self.parent.exec('umount', self.root / str(dst)[1:])
|
|
||||||
|
|
||||||
if self.root is not None:
|
|
||||||
await self.parent.exec('buildah', 'umount', self.ctr)
|
|
||||||
|
|
||||||
if self.ctr is not None:
|
if self.ctr is not None:
|
||||||
if result.status == 'success':
|
for src, dst in self.mounts.items():
|
||||||
await self.commit()
|
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)
|
await self.parent.exec('buildah', 'rm', self.ctr)
|
||||||
|
|
||||||
if result.status == 'success' and os.getenv('BUILDAH_PUSH'):
|
if result.status == 'success':
|
||||||
|
await self.commit()
|
||||||
|
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):
|
||||||
@ -184,13 +175,6 @@ class Buildah(Target):
|
|||||||
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}')
|
||||||
|
|
||||||
self.sha = (await self.parent.exec(
|
|
||||||
'buildah',
|
|
||||||
'commit',
|
|
||||||
'--format=' + image.format,
|
|
||||||
self.ctr,
|
|
||||||
)).out
|
|
||||||
|
|
||||||
ENV_TAGS = (
|
ENV_TAGS = (
|
||||||
# gitlab
|
# gitlab
|
||||||
'CI_COMMIT_SHORT_SHA',
|
'CI_COMMIT_SHORT_SHA',
|
||||||
@ -214,8 +198,7 @@ class Buildah(Target):
|
|||||||
else:
|
else:
|
||||||
tags = [image.repository]
|
tags = [image.repository]
|
||||||
|
|
||||||
for tag in tags:
|
await self.parent.exec('buildah', 'tag', self.image_previous, *tags)
|
||||||
await self.parent.exec('buildah', 'tag', self.sha, tag)
|
|
||||||
|
|
||||||
async def mkdir(self, path):
|
async def mkdir(self, path):
|
||||||
return await self.parent.mkdir(self.path(path))
|
return await self.parent.mkdir(self.path(path))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user