From 4310f47dee9ffc704841b987033c68bfd3641bfe Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 9 Feb 2015 12:16:43 -0500 Subject: [PATCH] Some code cleanup in the cached tag determination code --- buildman/jobutil/buildjob.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/buildman/jobutil/buildjob.py b/buildman/jobutil/buildjob.py index c69023aca..e507dab5f 100644 --- a/buildman/jobutil/buildjob.py +++ b/buildman/jobutil/buildjob.py @@ -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]