Some code cleanup in the cached tag determination code

This commit is contained in:
Joseph Schorr 2015-02-09 12:16:43 -05:00
parent 0065ac8503
commit 4310f47dee

View file

@ -82,15 +82,11 @@ class BuildJob(object):
in theory, provide "perfect" caching.
"""
# Lookup the base image in the repository. If it doesn't exist, nothing more to do.
repo_namespace = self._repo_build.repository.namespace_user.username
repo_name = self._repo_build.repository.name
repo_build = self.repo_build
repo_namespace = repo_build.repository.namespace_user.username
repo_name = repo_build.repository.name
repository = model.get_repository(repo_namespace, repo_name)
if repository is None:
# Should never happen, but just to be sure.
return None
current_image = model.get_image(repository, base_image_id)
current_image = model.get_image(repo_build.repository, base_image_id)
if current_image is None:
return None
@ -117,9 +113,8 @@ class BuildJob(object):
exists in the repository. This is a fallback for when no comment information is available.
"""
tags = self._build_config.get('docker_tags', ['latest'])
existing_tags = model.list_repository_tags(self._repo_build.repository.namespace_user.username,
self._repo_build.repository.name)
repository = self.repo_build.repository
existing_tags = model.list_repository_tags(repository.namespace_user.username, repository.name)
cached_tags = set(tags) & set([tag.name for tag in existing_tags])
if cached_tags:
return list(cached_tags)[0]