When cts_url is configured, use CTS /repo API for buildContainer yum_repourls.

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
This commit is contained in:
Jan Kaluza 2021-09-24 10:17:40 +02:00
parent 9612241396
commit 0530cf2712
2 changed files with 40 additions and 0 deletions

View File

@ -147,6 +147,15 @@ class OSBSThread(WorkerThread):
raise RuntimeError(
"There is no variant %s to get repo from to pass to OSBS." % repo
)
cts_url = compose.conf.get("cts_url", None)
if cts_url:
return os.path.join(
cts_url,
"api/1/composes",
compose.compose_id,
"repo/?variant=%s" % variant,
)
repo_path = compose.paths.compose.repository(
"$basearch", variant, create_dir=False
)

View File

@ -364,6 +364,37 @@ class OSBSThreadTest(helpers.PungiTestCase):
) as f:
self.assertIn("baseurl=http://example.com/repo\n", f)
@mock.patch("pungi.phases.osbs.kojiwrapper.KojiWrapper")
def test_run_with_extra_repos_with_cts(self, KojiWrapper):
cfg = {
"url": "git://example.com/repo?#BEEFCAFE",
"target": "f24-docker-candidate",
"git_branch": "f24-docker",
"name": "my-name",
"version": "1.0",
"repo": [
"Everything",
],
}
self.compose.conf["cts_url"] = "http://cts.localhost"
self._setupMock(KojiWrapper)
self._assertConfigCorrect(cfg)
self.t.process((self.compose, self.compose.variants["Server"], cfg), 1)
cts_url = "http://cts.localhost/api/1/composes/%s" % self.compose.compose_id
options = {
"name": "my-name",
"version": "1.0",
"git_branch": "f24-docker",
"yum_repourls": [
"%s/repo/?variant=Server" % cts_url,
"%s/repo/?variant=Everything" % cts_url,
],
}
self._assertCorrectCalls(options)
self._assertCorrectMetadata()
@mock.patch("pungi.phases.osbs.kojiwrapper.KojiWrapper")
def test_run_with_deprecated_registry(self, KojiWrapper):
cfg = {