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
This commit is contained in:
Charlton Austin 2017-05-08 17:18:03 -04:00
parent 191e5d94d4
commit 3b728014ac

View file

@ -334,35 +334,29 @@ class BuildTriggerAnalyze(RepositoryParamResource):
} }
try: try:
# Default to the current namespace.
base_namespace = namespace_name
base_repository = None
# Load the contents of the Dockerfile. # Load the contents of the Dockerfile.
contents = handler.load_dockerfile_contents() contents = handler.load_dockerfile_contents()
if not contents: if not contents:
return { return analyze_view(base_namespace, base_repository, 'warning',
'status': 'warning', message='Specified Dockerfile path for the trigger was not found on the main ' +
'message': 'Specified Dockerfile path for the trigger was not found on the main ' + 'branch. This trigger may fail.')
'branch. This trigger may fail.',
}
# Parse the contents of the Dockerfile. # Parse the contents of the Dockerfile.
parsed = parse_dockerfile(contents) parsed = parse_dockerfile(contents)
if not parsed: if not parsed:
return { return analyze_view(base_namespace, base_repository, 'error',
'status': 'error', message='Could not parse the Dockerfile specified')
'message': 'Could not parse the Dockerfile specified'
}
# Check whether the dockerfile_path is correct # Check whether the dockerfile_path is correct
if new_config_dict.get('context'): if new_config_dict.get('context'):
if not is_parent(new_config_dict.get('context'), new_config_dict.get('dockerfile_path')): if not is_parent(new_config_dict.get('context'), new_config_dict.get('dockerfile_path')):
return { return analyze_view(base_namespace, base_repository, 'error',
'status': 'error', message='Dockerfile, %s, is not child of the context, %s.' %
'message': 'Dockerfile, %s, is not child of the context, %s.' % (new_config_dict.get('context'), new_config_dict.get('dockerfile_path')))
(new_config_dict.get('context'), new_config_dict.get('dockerfile_path'))
}
# Default to the current namespace.
base_namespace = namespace_name
base_repository = None
# Determine the base image (i.e. the FROM) for the Dockerfile. # Determine the base image (i.e. the FROM) for the Dockerfile.
base_image = parsed.get_base_image() base_image = parsed.get_base_image()