Added Container strategy
This commit is contained in:
parent
a720e22a50
commit
b771e9bd1a
@ -1,2 +1,3 @@
|
||||
from .asyn import Async
|
||||
from .script import Script
|
||||
from .pod import Pod, Container
|
||||
|
||||
42
shlax/strategies/pod.py
Normal file
42
shlax/strategies/pod.py
Normal 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
|
||||
@ -27,6 +27,10 @@ build = Buildah(
|
||||
Pip('/app'),
|
||||
commit='yourlabs/shlax',
|
||||
workdir='/app',
|
||||
)
|
||||
|
||||
shlax = Container(
|
||||
build=build,
|
||||
test=test,
|
||||
)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user