From 2657a12c96f24725cb67f7521847fa3165c9a1da Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Thu, 13 Aug 2020 13:22:43 +0200 Subject: [PATCH] Allow setting CTS parent_compose_ids using --parent-compose-id option. This is needed to track dependencies between composes in the Compose Tracking Service. Signed-off-by: Jan Kaluza --- pungi/compose.py | 6 +++++- pungi/scripts/pungi_koji.py | 12 +++++++++++- tests/test_compose.py | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pungi/compose.py b/pungi/compose.py index aa682815..bf010647 100644 --- a/pungi/compose.py +++ b/pungi/compose.py @@ -57,6 +57,7 @@ def get_compose_info( compose_date=None, compose_respin=None, compose_label=None, + parent_compose_ids=None, ): """ Creates inncomplete ComposeInfo to generate Compose ID @@ -100,7 +101,10 @@ def get_compose_info( # Create compose in CTS and get the reserved compose ID. ci.compose.id = ci.create_compose_id() url = os.path.join(cts_url, "api/1/composes/") - data = {"compose_info": json.loads(ci.dumps())} + data = { + "compose_info": json.loads(ci.dumps()), + "parent_compose_ids": parent_compose_ids, + } rv = requests.post(url, json=data, auth=HTTPKerberosAuth()) rv.raise_for_status() finally: diff --git a/pungi/scripts/pungi_koji.py b/pungi/scripts/pungi_koji.py index 7631f006..aa969309 100644 --- a/pungi/scripts/pungi_koji.py +++ b/pungi/scripts/pungi_koji.py @@ -158,6 +158,13 @@ def main(): default=-1, help="number of product version components used when creating latest symlink", # noqa: E501 ) + parser.add_argument( + "--parent-compose-id", + action="append", + default=[], + help="List of compose IDs which should be marked as parents of this " + "compose in Compose Tracking Service", + ) parser.add_argument( "--print-output-dir", action="store_true", @@ -282,7 +289,10 @@ def main(): ci_path = os.path.join(compose_dir, "work", "global", "composeinfo-base.json") if not os.path.exists(ci_path): ci = Compose.get_compose_info( - conf, compose_type=compose_type, compose_label=opts.label + conf, + compose_type=compose_type, + compose_label=opts.label, + parent_compose_ids=opts.parent_compose_id, ) Compose.write_compose_info(compose_dir, ci) diff --git a/tests/test_compose.py b/tests/test_compose.py index db8fab6f..c06c3bb9 100644 --- a/tests/test_compose.py +++ b/tests/test_compose.py @@ -648,7 +648,7 @@ class ComposeTestCase(unittest.TestCase): mocked_requests.post.assert_called_once_with( "https://cts.localhost.tld/api/1/composes/", auth=mock.ANY, - json={"compose_info": self.ci_json}, + json={"compose_info": self.ci_json, "parent_compose_ids": None}, )