Some code cleanup in the cached tag determination code
This commit is contained in:
parent
0065ac8503
commit
4310f47dee
1 changed files with 6 additions and 11 deletions
|
@ -82,15 +82,11 @@ class BuildJob(object):
|
||||||
in theory, provide "perfect" caching.
|
in theory, provide "perfect" caching.
|
||||||
"""
|
"""
|
||||||
# Lookup the base image in the repository. If it doesn't exist, nothing more to do.
|
# 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_build = self.repo_build
|
||||||
repo_name = self._repo_build.repository.name
|
repo_namespace = repo_build.repository.namespace_user.username
|
||||||
|
repo_name = repo_build.repository.name
|
||||||
|
|
||||||
repository = model.get_repository(repo_namespace, repo_name)
|
current_image = model.get_image(repo_build.repository, base_image_id)
|
||||||
if repository is None:
|
|
||||||
# Should never happen, but just to be sure.
|
|
||||||
return None
|
|
||||||
|
|
||||||
current_image = model.get_image(repository, base_image_id)
|
|
||||||
if current_image is None:
|
if current_image is None:
|
||||||
return 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.
|
exists in the repository. This is a fallback for when no comment information is available.
|
||||||
"""
|
"""
|
||||||
tags = self._build_config.get('docker_tags', ['latest'])
|
tags = self._build_config.get('docker_tags', ['latest'])
|
||||||
existing_tags = model.list_repository_tags(self._repo_build.repository.namespace_user.username,
|
repository = self.repo_build.repository
|
||||||
self._repo_build.repository.name)
|
existing_tags = model.list_repository_tags(repository.namespace_user.username, repository.name)
|
||||||
|
|
||||||
cached_tags = set(tags) & set([tag.name for tag in existing_tags])
|
cached_tags = set(tags) & set([tag.name for tag in existing_tags])
|
||||||
if cached_tags:
|
if cached_tags:
|
||||||
return list(cached_tags)[0]
|
return list(cached_tags)[0]
|
||||||
|
|
Reference in a new issue