Merge pull request #2246 from coreos-inc/build-none-error

Add check for None repository in start build API
This commit is contained in:
josephschorr 2016-12-19 11:44:15 -05:00 committed by GitHub
commit cc9e8cd2d0

View file

@ -273,10 +273,12 @@ class RepositoryBuildList(RepositoryParamResource):
# Start the build.
repo = model.repository.get_repository(namespace, repository)
if repo is None:
raise NotFound()
build_name = (user_files.get_file_checksum(dockerfile_id)
if dockerfile_id
else hashlib.sha224(archive_url).hexdigest()[0:7])
build_name = (user_files.get_file_checksum(dockerfile_id)
if dockerfile_id
else hashlib.sha224(archive_url).hexdigest()[0:7])
prepared = PreparedBuild()
prepared.build_name = build_name
@ -317,6 +319,9 @@ class RepositoryBuildResource(RepositoryParamResource):
except model.build.InvalidRepositoryBuildException:
raise NotFound()
if build.repository.name != repository or build.repository.namespace_user.username != namespace:
raise NotFound()
return build_status_view(build)
@require_repo_admin