fix broken Docker build and helm package

This commit is contained in:
Jens Langhammer 2019-02-26 12:34:51 +01:00
parent 06b65a7882
commit edfe0e5450
3 changed files with 10 additions and 18 deletions

View File

@ -52,7 +52,7 @@ package-docker:
name: gcr.io/kaniko-project/executor:debug name: gcr.io/kaniko-project/executor:debug
entrypoint: [""] entrypoint: [""]
before_script: before_script:
- echo "{\"auths\":{\"https://docker.$NEXUS_URL/\":{\"username\":\"$NEXUS_USER\",\"password\":\"$NEXUS_PASS\"}}}" > /kaniko/.docker/config.json - echo "{\"auths\":{\"docker.$NEXUS_URL\":{\"auth\":\"$NEXUS_AUTH\"}}}" > /kaniko/.docker/config.json
script: script:
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination docker.pkg.beryju.org/passbook:latest --destination docker.pkg.beryju.org/passbook:0.0.8-alpha - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination docker.pkg.beryju.org/passbook:latest --destination docker.pkg.beryju.org/passbook:0.0.8-alpha
stage: build stage: build
@ -65,7 +65,7 @@ package-helm:
- curl https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash - curl https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash
- helm init --client-only - helm init --client-only
- helm package helm/passbook - helm package helm/passbook
- ./manage.py nexus_upload --method put --url $NEXUS_URL --user $NEXUS_USER --password $NEXUS_PASS --repo helm *.tgz - ./manage.py nexus_upload --method put --url $NEXUS_URL --auth $NEXUS_AUTH --repo helm *.tgz
only: only:
- tags - tags
- /^version/.*$/ - /^version/.*$/

View File

@ -2,5 +2,5 @@ apiVersion: v1
appVersion: "0.0.8-alpha" appVersion: "0.0.8-alpha"
description: A Helm chart for passbook. description: A Helm chart for passbook.
name: passbook name: passbook
version: 1.0.0 version: "0.0.8-alpha"
icon: https://passbook.beryju.org/images/logo.png icon: https://passbook.beryju.org/images/logo.png

View File

@ -1,5 +1,5 @@
"""passbook nexus_upload management command""" """passbook nexus_upload management command"""
from getpass import getpass from base64 import b64decode
import requests import requests
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
@ -24,9 +24,9 @@ class Command(BaseCommand):
help='Nexus root URL', help='Nexus root URL',
required=True) required=True)
parser.add_argument( parser.add_argument(
'--user', '--auth',
action='store', action='store',
help='Username to use for Nexus upload', help='base64-encoded string of username:password',
required=True) required=True)
parser.add_argument( parser.add_argument(
'--method', '--method',
@ -37,29 +37,21 @@ class Command(BaseCommand):
help=('Method used for uploading files to nexus. ' help=('Method used for uploading files to nexus. '
'Apt repositories use post, Helm uses put.'), 'Apt repositories use post, Helm uses put.'),
required=True) required=True)
parser.add_argument(
'--password',
action='store',
help=("Password to use for Nexus upload. "
"If parameter not given, we'll interactively ask"))
# Positional arguments # Positional arguments
parser.add_argument('file', nargs='+', type=str) parser.add_argument('file', nargs='+', type=str)
def handle(self, *args, **options): def handle(self, *args, **options):
"""Upload debian package to nexus repository""" """Upload debian package to nexus repository"""
if options.get('password') is None: auth = tuple(b64decode(options.get('auth')).decode('utf-8').split(':', 1))
options['password'] = getpass()
responses = {} responses = {}
url = 'https://%(url)s/repository/%(repo)s//' % options url = 'https://%(url)s/repository/%(repo)s/' % options
method = options.get('method') method = options.get('method')
exit_code = 0 exit_code = 0
for file in options.get('file'): for file in options.get('file'):
if method == 'post': if method == 'post':
responses[file] = requests.post(url, data=open(file, mode='rb'), responses[file] = requests.post(url, data=open(file, mode='rb'), auth=auth)
auth=(options.get('user'), options.get('password')))
else: else:
responses[file] = requests.put(url+file, data=open(file, mode='rb'), responses[file] = requests.put(url+file, data=open(file, mode='rb'), auth=auth)
auth=(options.get('user'), options.get('password')))
self.stdout.write('Upload results:\n') self.stdout.write('Upload results:\n')
sep = '-' * 60 sep = '-' * 60
self.stdout.write('%s\n' % sep) self.stdout.write('%s\n' % sep)