Fix login
This commit is contained in:
parent
3ea029efec
commit
f4844b0e73
@ -111,8 +111,9 @@ 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 self.call(*args, **kwargs)
|
||||
result = await call(*args, **kwargs)
|
||||
except Exception as e:
|
||||
self.output_fail(e)
|
||||
self.status = 'fail'
|
||||
|
||||
@ -25,13 +25,14 @@ class Output:
|
||||
def colorize(self, code, content):
|
||||
return self.color(code) + content + self.color()
|
||||
|
||||
def __init__(self, prefix=None, regexps=None, debug=False, write=None, flush=None):
|
||||
def __init__(self, prefix=None, regexps=None, debug=False, write=None, flush=None, **kwargs):
|
||||
self.prefix = prefix
|
||||
self.debug = debug
|
||||
self.prefix_length = 0
|
||||
self.regexps = regexps or dict()
|
||||
self.write = write or sys.stdout.buffer.write
|
||||
self.flush = flush or sys.stdout.flush
|
||||
self.kwargs = kwargs
|
||||
|
||||
def prefix_line(self):
|
||||
if self.prefix not in self.prefixes:
|
||||
|
||||
@ -18,22 +18,7 @@ class Container(Script):
|
||||
)(*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}')
|
||||
await self.kwargs['build'](method='push', **kwargs)
|
||||
|
||||
#name = kwargs.get('name', os.getcwd()).split('/')[-1]
|
||||
|
||||
|
||||
@ -143,17 +143,15 @@ class Buildah(Localhost):
|
||||
for tag in tags:
|
||||
await self.exec('buildah', 'tag', self.sha, tag, buildah=False)
|
||||
|
||||
async def push(self):
|
||||
async def push(self, *args, **kwargs):
|
||||
user = os.getenv('DOCKER_USER')
|
||||
passwd = os.getenv('DOCKER_PASS')
|
||||
if user and passwd and os.getenv('CI'):
|
||||
if user and passwd:
|
||||
self.output.cmd('buildah login -u ... -p ...' + self.image.registry)
|
||||
old = self.output.debug
|
||||
self.output.debug = False
|
||||
await self.exec('buildah', 'login', '-u', user, '-p', passwd, self.image.registry or 'docker.io', )
|
||||
self.output.debug = old
|
||||
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', self.image.registry or 'docker.io', f'{self.image.repository}:{tag}')
|
||||
await self.exec('buildah', 'push', f'{self.image.repository}:{tag}')
|
||||
|
||||
async def clean(self, *args, **kwargs):
|
||||
if self.is_runnable():
|
||||
@ -162,7 +160,7 @@ class Buildah(Localhost):
|
||||
|
||||
if self.status == 'success':
|
||||
await self.commit()
|
||||
if 'push' in args:
|
||||
if 'push' in args or os.getenv('CI'):
|
||||
await self.push()
|
||||
|
||||
if self.mnt is not None:
|
||||
|
||||
@ -30,7 +30,8 @@ class Localhost(Script):
|
||||
return args, kwargs
|
||||
|
||||
async def exec(self, *args, **kwargs):
|
||||
kwargs.setdefault('debug', self.call_kwargs.get('debug', False))
|
||||
if 'debug' not in kwargs:
|
||||
kwargs['debug'] = getattr(self, 'call_kwargs', {}).get('debug', False)
|
||||
kwargs.setdefault('output', self.output)
|
||||
args, kwargs = self.shargs(*args, **kwargs)
|
||||
proc = await Proc(*args, **kwargs)()
|
||||
|
||||
12
shlaxfile.py
12
shlaxfile.py
@ -35,17 +35,17 @@ shlax = Container(
|
||||
)
|
||||
|
||||
gitlabci = GitLabCI(
|
||||
build=dict(
|
||||
test=dict(
|
||||
stage='build',
|
||||
script='pip install -U --user -e .[test] && ' + PYTEST,
|
||||
image='yourlabs/python',
|
||||
),
|
||||
build=dict(
|
||||
stage='test',
|
||||
image='yourlabs/shlax',
|
||||
script='pip install -U --user -e . && CACHE_DIR=$(pwd)/.cache ./shlaxfile.py -d shlax build push',
|
||||
cache=dict(paths=['.cache'], key='cache'),
|
||||
),
|
||||
test=dict(
|
||||
stage='test',
|
||||
script='pip install -U --user -e . && ./shlaxfile.py -d test',
|
||||
image=build,
|
||||
),
|
||||
pypi=dict(
|
||||
stage='deploy',
|
||||
only=['tags'],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user