From 3b728014ac5fa2de49dafb106a07ff7f977fcbe3 Mon Sep 17 00:00:00 2001 From: Charlton Austin Date: Mon, 8 May 2017 17:18:03 -0400 Subject: [PATCH] fix(trigger.py): fixed robot view no dockerfile fixed how we create views where there is no dockerfile available [TESTING -> local with dockerfile build] Issue: https://www.pivotaltracker.com/story/show/144661631 - [ ] It works! - [ ] Comments provide sufficient explanations for the next contributor - [ ] Tests cover changes and corner cases - [ ] Follows Quay syntax patterns and format --- endpoints/api/trigger.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/endpoints/api/trigger.py b/endpoints/api/trigger.py index 1d2d3ac18..e9d036110 100644 --- a/endpoints/api/trigger.py +++ b/endpoints/api/trigger.py @@ -334,35 +334,29 @@ class BuildTriggerAnalyze(RepositoryParamResource): } try: + # Default to the current namespace. + base_namespace = namespace_name + base_repository = None + # Load the contents of the Dockerfile. contents = handler.load_dockerfile_contents() if not contents: - return { - 'status': 'warning', - 'message': 'Specified Dockerfile path for the trigger was not found on the main ' + - 'branch. This trigger may fail.', - } + return analyze_view(base_namespace, base_repository, 'warning', + message='Specified Dockerfile path for the trigger was not found on the main ' + + 'branch. This trigger may fail.') # Parse the contents of the Dockerfile. parsed = parse_dockerfile(contents) if not parsed: - return { - 'status': 'error', - 'message': 'Could not parse the Dockerfile specified' - } + return analyze_view(base_namespace, base_repository, 'error', + message='Could not parse the Dockerfile specified') # Check whether the dockerfile_path is correct if new_config_dict.get('context'): if not is_parent(new_config_dict.get('context'), new_config_dict.get('dockerfile_path')): - return { - 'status': 'error', - 'message': 'Dockerfile, %s, is not child of the context, %s.' % - (new_config_dict.get('context'), new_config_dict.get('dockerfile_path')) - } - - # Default to the current namespace. - base_namespace = namespace_name - base_repository = None + return analyze_view(base_namespace, base_repository, 'error', + message='Dockerfile, %s, is not child of the context, %s.' % + (new_config_dict.get('context'), new_config_dict.get('dockerfile_path'))) # Determine the base image (i.e. the FROM) for the Dockerfile. base_image = parsed.get_base_image()