Fixing push

This commit is contained in:
jpic 2020-10-08 00:50:30 +02:00
parent 3a45cdef4a
commit b48e997a4b
4 changed files with 28 additions and 20 deletions

View File

@ -5,17 +5,17 @@ build:
image: yourlabs/buildah image: yourlabs/buildah
script: script:
- pip3 install -U --user -e .[cli] - pip3 install -U --user -e .[cli]
- CACHE_DIR=$(pwd)/.cache python3 ./shlaxfile.py build - CACHE_DIR=$(pwd)/.cache python3 ./shlaxfile.py build push
stage: build stage: build
# commenting until we have docker again
# build-itself: build-itself:
# cache: cache:
# key: cache key: cache
# paths: [.cache] paths: [.cache]
# image: shlax:$CI_COMMIT_SHORT_SHA image: quay.io/yourlabs/shlax:$CI_COMMIT_SHORT_SHA
# script: python3 ./shlaxfile.py build script: python3 ./shlaxfile.py build
# stage: test stage: test
#
test: test:
image: yourlabs/python image: yourlabs/python
stage: build stage: build

View File

@ -74,13 +74,19 @@ class Image:
def __str__(self): def __str__(self):
return f'{self.repository}:{self.tags[-1]}' return f'{self.repository}:{self.tags[-1]}'
async def push(self, *args, **kwargs): async def push(self, target):
user = os.getenv('DOCKER_USER') user = os.getenv('IMAGES_USER')
passwd = os.getenv('DOCKER_PASS') passwd = os.getenv('IMAGES_PASS')
action = kwargs.get('action', self)
if user and passwd: if user and passwd:
action.output.cmd('buildah login -u ... -p ...' + self.registry) target.output.cmd('buildah login -u ... -p ...' + self.registry)
await action.exec('buildah', 'login', '-u', user, '-p', passwd, self.registry or 'docker.io', debug=False) await target.parent.exec(
'buildah', 'login', '-u', user, '-p', passwd,
self.registry or 'docker.io', debug=False)
for tag in self.tags: for tag in self.tags:
await action.exec('buildah', 'push', f'{self.repository}:{tag}') await target.parent.exec(
'buildah',
'push',
self.repository + ':final',
f'{self.registry}/{self.repository}:{tag}'
)

View File

@ -37,10 +37,12 @@ class Buildah(Target):
return 'Replacing with: buildah unshare ' + ' '.join(sys.argv) return 'Replacing with: buildah unshare ' + ' '.join(sys.argv)
return f'Buildah({self.image})' return f'Buildah({self.image})'
async def __call__(self, *actions, target=None): async def __call__(self, *actions, target=None, push: bool=False):
if target: if target:
self.parent = target self.parent = target
self.push = push
if not self.is_runnable(): if not self.is_runnable():
os.execvp('buildah', ['buildah', 'unshare'] + sys.argv) os.execvp('buildah', ['buildah', 'unshare'] + sys.argv)
return # process has been replaced return # process has been replaced
@ -124,7 +126,7 @@ class Buildah(Target):
if result.status == 'success' and self.ctr: if result.status == 'success' and self.ctr:
await self.commit() await self.commit()
if os.getenv('BUILDAH_PUSH'): if self.push:
await self.image.push(target) await self.image.push(target)
if self.ctr is not None: if self.ctr is not None:

View File

@ -11,7 +11,7 @@ shlax = Container(
Copy('setup.py', 'shlax', '/app'), Copy('setup.py', 'shlax', '/app'),
Pip('/app'), Pip('/app'),
base='quay.io/podman/stable', base='quay.io/podman/stable',
commit='shlax', commit='quay.io/yourlabs/shlax',
), ),
) )