diff --git a/shlax/actions/base.py b/shlax/actions/base.py index 3872926..d2e0e76 100644 --- a/shlax/actions/base.py +++ b/shlax/actions/base.py @@ -111,9 +111,8 @@ class Action: self.output = self.output_factory(*args, **kwargs) self.output_start() self.status = 'running' - call = getattr(self, kwargs.pop('method', 'call')) try: - result = await call(*args, **kwargs) + result = await self.call(*args, **kwargs) except Exception as e: self.output_fail(e) self.status = 'fail' diff --git a/shlax/image.py b/shlax/image.py index bee742f..80b4562 100644 --- a/shlax/image.py +++ b/shlax/image.py @@ -62,3 +62,14 @@ class Image: def __str__(self): return f'{self.repository}:{self.tags[-1]}' + + async def push(self, *args, **kwargs): + user = os.getenv('DOCKER_USER') + passwd = os.getenv('DOCKER_PASS') + action = kwargs.get('action', self) + if user and passwd: + action.output.cmd('buildah login -u ... -p ...' + self.registry) + await action.exec('buildah', 'login', '-u', user, '-p', passwd, self.registry or 'docker.io', debug=False) + + for tag in self.tags: + await action.exec('buildah', 'push', f'{self.repository}:{tag}') diff --git a/shlax/output.py b/shlax/output.py index 18e58b2..9a8955f 100644 --- a/shlax/output.py +++ b/shlax/output.py @@ -119,7 +119,7 @@ class Output: ])) def start(self, action): - if self.debug is True: + if self.debug is True or 'visit' in str(self.debug): self(''.join([ self.colors['orangebold'], '⚠ START ', diff --git a/shlax/strategies/pod.py b/shlax/strategies/pod.py index 6f496bf..97da07c 100644 --- a/shlax/strategies/pod.py +++ b/shlax/strategies/pod.py @@ -18,7 +18,7 @@ class Container(Script): )(**kwargs) if not args or 'push' in args: - await self.kwargs['build'](method='push', **kwargs) + await self.image.push(action=self) #name = kwargs.get('name', os.getcwd()).split('/')[-1] diff --git a/shlax/targets/buildah.py b/shlax/targets/buildah.py index 11860c5..bf5e28c 100644 --- a/shlax/targets/buildah.py +++ b/shlax/targets/buildah.py @@ -55,10 +55,6 @@ class Buildah(Localhost): def __repr__(self): return f'Base({self.base})' - async def __call__(self, *args, **kwargs): - result = await super().__call__(*args, **kwargs) - return result - async def config(self, line): """Run buildah config.""" return await self.exec(f'buildah config {line} {self.ctr}', buildah=False) @@ -143,16 +139,6 @@ class Buildah(Localhost): for tag in tags: await self.exec('buildah', 'tag', self.sha, tag, buildah=False) - async def push(self, *args, **kwargs): - user = os.getenv('DOCKER_USER') - passwd = os.getenv('DOCKER_PASS') - if user and passwd: - self.output.cmd('buildah login -u ... -p ...' + self.image.registry) - await self.exec('buildah', 'login', '-u', user, '-p', passwd, self.image.registry or 'docker.io', debug=False) - - for tag in self.image.tags: - await self.exec('buildah', 'push', f'{self.image.repository}:{tag}') - async def clean(self, *args, **kwargs): if self.is_runnable(): for src, dst in self.mounts.items(): @@ -161,7 +147,7 @@ class Buildah(Localhost): if self.status == 'success': await self.commit() if 'push' in args: - await self.push() + await self.image.push(action=self) if self.mnt is not None: await self.exec('buildah', 'umount', self.ctr, buildah=False)