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 <jkaluza@redhat.com>
This commit is contained in:
Jan Kaluza 2020-08-13 13:22:43 +02:00
parent 7a6d8303dc
commit 2657a12c96
3 changed files with 17 additions and 3 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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},
)