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