From 08ba9f8d7d01c9bb50ccf68e21482ccb9fd97f03 Mon Sep 17 00:00:00 2001 From: Luiz Carvalho Date: Jul 15 2019 15:40:58 +0000 Subject: Ignore container repos without auto_release_tags Ticket-ID: FACTORY-4108 Signed-off-by: Luiz Carvalho --- diff --git a/freshmaker/lightblue.py b/freshmaker/lightblue.py index 9f7b831..28e2334 100644 --- a/freshmaker/lightblue.py +++ b/freshmaker/lightblue.py @@ -645,8 +645,10 @@ class LightBlue(object): repos = [] for repo_data in response['processed']: - if "auto_rebuild_tags" not in repo_data: - repo_data["auto_rebuild_tags"] = ["latest"] + if not repo_data.get('auto_rebuild_tags'): + log.info('"auto_rebuild_tags" not set for %s repository, ignoring repository', + repo_data["repository"]) + continue repo = ContainerRepository() repo.update(repo_data) repos.append(repo) diff --git a/tests/test_lightblue.py b/tests/test_lightblue.py index 4ab3d48..7218665 100644 --- a/tests/test_lightblue.py +++ b/tests/test_lightblue.py @@ -826,14 +826,28 @@ class TestQueryEntityFromLightBlue(helpers.FreshmakerTestCase): 'metrics': { 'pulls_in_last_30_days': 0, 'last_update_date': '20170223T08:28:40.913-0500' - } + }, + 'repository': 'spam', + 'auto_rebuild_tags': ['latest'], }, { 'creationDate': '20161020T04:52:43.365-0400', 'metrics': { 'last_update_date': '20170501T03:00:19.892-0400', 'pulls_in_last_30_days': 20 - } + }, + 'repository': 'bacon', + 'auto_rebuild_tags': ['latest'], + }, + { + 'creationDate': '20161020T04:52:43.365-0400', + 'metrics': { + 'last_update_date': '20170501T03:00:19.892-0400', + 'pulls_in_last_30_days': 20 + }, + # This repository is ignored by Freshmaker because it does not + # have auto_rebuild_tags set. + 'repository': 'ignored-due-to-missing-tags', } ], 'entityVersion': '0.0.11', @@ -871,6 +885,9 @@ class TestQueryEntityFromLightBlue(helpers.FreshmakerTestCase): self.assertEqual('20170223T08:28:40.913-0500', repo['metrics']['last_update_date']) self.assertEqual(["latest"], repo["auto_rebuild_tags"]) + self.assertEqual(repos[0]['repository'], 'spam') + self.assertEqual(repos[1]['repository'], 'bacon') + @patch('freshmaker.lightblue.requests.post') def test_raise_error_if_request_data_is_incorrect(self, post): post.return_value.status_code = http_client.BAD_REQUEST