Added Container strategy

This commit is contained in:
jpic 2020-02-16 17:45:04 +01:00
parent a720e22a50
commit b771e9bd1a
3 changed files with 47 additions and 0 deletions

View File

@ -1,2 +1,3 @@
from .asyn import Async from .asyn import Async
from .script import Script from .script import Script
from .pod import Pod, Container

42
shlax/strategies/pod.py Normal file
View File

@ -0,0 +1,42 @@
import os
from .script import Script
class Container(Script):
async def call(self, *args, **kwargs):
if not args or 'build' in args:
await self.kwargs['build'](*args, **kwargs)
self.image = self.kwargs['build'].image
if not args or 'test' in args:
self.output.test(self)
await self.action('Docker',
*self.kwargs['test'].actions,
image=self.image,
mount={'.': '/app'},
workdir='/app',
)(*args, **kwargs)
if not args or 'push' in args:
user = os.getenv('DOCKER_USER')
passwd = os.getenv('DOCKER_PASS')
if user and passwd and os.getenv('CI') and self.registry:
await self.exec(
'podman',
'login',
'-u',
user,
'-p',
passwd,
self.registry,
buildah=False,
)
for tag in self.image.tags:
await self.exec('podman', 'push', f'{self.image.repository}:{tag}')
#name = kwargs.get('name', os.getcwd()).split('/')[-1]
class Pod(Script):
pass

View File

@ -27,6 +27,10 @@ build = Buildah(
Pip('/app'), Pip('/app'),
commit='yourlabs/shlax', commit='yourlabs/shlax',
workdir='/app', workdir='/app',
)
shlax = Container(
build=build,
test=test, test=test,
) )