Prevent double clean
This commit is contained in:
parent
ba87dea428
commit
ee25255028
@ -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'
|
||||
|
||||
@ -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}')
|
||||
|
||||
@ -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 ',
|
||||
|
||||
@ -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]
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user