buildcomponent: handle builds without resource_key
This commit is contained in:
parent
d29c8d60c7
commit
cd1b003ca6
4 changed files with 20 additions and 6 deletions
|
@ -4,13 +4,13 @@ import os.path
|
|||
import tarfile
|
||||
import base64
|
||||
import re
|
||||
import json
|
||||
|
||||
from github import Github, UnknownObjectException, GithubException
|
||||
from tempfile import SpooledTemporaryFile
|
||||
|
||||
from app import app, userfiles as user_files, github_trigger
|
||||
from util.tarfileappender import TarfileAppender
|
||||
from endpoints.api.build import get_trigger_config
|
||||
|
||||
|
||||
client = app.config['HTTPCLIENT']
|
||||
|
@ -147,6 +147,12 @@ class BuildTrigger(object):
|
|||
def raise_unsupported():
|
||||
raise io.UnsupportedOperation
|
||||
|
||||
def get_trigger_config(trigger):
|
||||
try:
|
||||
return json.loads(trigger.config)
|
||||
except:
|
||||
return {}
|
||||
|
||||
|
||||
class GithubBuildTrigger(BuildTrigger):
|
||||
"""
|
||||
|
@ -405,6 +411,9 @@ class GithubBuildTrigger(BuildTrigger):
|
|||
dockerfile_id = user_files.store_file(appender, TARBALL_MIME)
|
||||
|
||||
logger.debug('Successfully prepared job')
|
||||
else:
|
||||
dockerfile_id = None
|
||||
|
||||
|
||||
# compute the tag(s)
|
||||
branch = ref.split('/')[-1]
|
||||
|
@ -417,7 +426,10 @@ class GithubBuildTrigger(BuildTrigger):
|
|||
|
||||
# compute the subdir
|
||||
repo_subdir = config['subdir']
|
||||
joined_subdir = os.path.join(tarball_subdir, repo_subdir)
|
||||
if trigger.private_key is None:
|
||||
joined_subdir = os.path.join(tarball_subdir, repo_subdir)
|
||||
else:
|
||||
joined_subdir = repo_subdir
|
||||
logger.debug('Final subdir: %s', joined_subdir)
|
||||
|
||||
# compute the metadata
|
||||
|
|
Reference in a new issue