Prepare the build worker to support multiple tags and subdirectories. Change the build database config to accept a job config object instead of breaking out the parameters into independent blocks.
This commit is contained in:
parent
4b0f4c0a7b
commit
13dea98499
9 changed files with 114 additions and 53 deletions
|
@ -1144,7 +1144,7 @@ def build_status_view(build_obj, can_write=False):
|
|||
'started': build_obj.started,
|
||||
'display_name': build_obj.display_name,
|
||||
'status': status,
|
||||
'resource_key': build_obj.resource_key if can_write else None,
|
||||
'job_config': json.loads(build_obj.job_config) if can_write else None,
|
||||
'is_writer': can_write,
|
||||
'trigger': trigger_view(build_obj.trigger),
|
||||
}
|
||||
|
@ -1234,11 +1234,13 @@ def request_repo_build(namespace, repository):
|
|||
logger.debug('User requested repository initialization.')
|
||||
dockerfile_id = request.get_json()['file_id']
|
||||
|
||||
# Check if the dockerfile resource has already been used. If so, then it can only be reused if the
|
||||
# user has access to the repository for which it was used.
|
||||
# Check if the dockerfile resource has already been used. If so, then it
|
||||
# can only be reused if the user has access to the repository for which it
|
||||
# was used.
|
||||
associated_repository = model.get_repository_for_resource(dockerfile_id)
|
||||
if associated_repository:
|
||||
if not ModifyRepositoryPermission(associated_repository.namespace, associated_repository.name):
|
||||
if not ModifyRepositoryPermission(associated_repository.namespace,
|
||||
associated_repository.name):
|
||||
abort(403)
|
||||
|
||||
# Start the build.
|
||||
|
@ -1248,9 +1250,15 @@ def request_repo_build(namespace, repository):
|
|||
logger.debug('**********Md5: %s' % display_name)
|
||||
|
||||
host = urlparse.urlparse(request.url).netloc
|
||||
tag = '%s/%s/%s' % (host, repo.namespace, repo.name)
|
||||
build_request = model.create_repository_build(repo, token, dockerfile_id,
|
||||
tag, display_name)
|
||||
repo = '%s/%s/%s' % (host, repo.namespace, repo.name)
|
||||
job_config = {
|
||||
'docker_tags': ['latest'],
|
||||
'build_subdir': '',
|
||||
'repository': repo,
|
||||
'resource_key': dockerfile_id,
|
||||
}
|
||||
build_request = model.create_repository_build(repo, token, job_config,
|
||||
display_name)
|
||||
dockerfile_build_queue.put(json.dumps({
|
||||
'build_uuid': build_request.uuid,
|
||||
'namespace': namespace,
|
||||
|
|
Reference in a new issue