From 195bfbefa4f4936c235d83993a7da39cdeb16533 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Thu, 9 Sep 2021 08:49:31 +0200 Subject: [PATCH] Allow specifying $COMPOSE_ID in the `repo` value for osbs phase. There should be an option for `yum_repourls` to point to static URL, for example when CTS is used. The idea is that instead of setting `repo` to `AppStream`, we could use link similar to this one: `https://cts.localhost/api/1/composes/$COMPOSE_ID/repo/?variant=AppStream` This would be translated to real static link during the OSBS phase: `https://cts.localhost/api/1/composes/CentOS-Stream-9-20210803.0/repo/?variant=AppStream` That way this statis link would appear in the yum_repourls. Merges: https://pagure.io/pungi/pull-request/1543 Signed-off-by: Jan Kaluza --- doc/configuration.rst | 6 ++++-- pungi/phases/osbs.py | 2 +- tests/test_osbs_phase.py | 8 +++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/doc/configuration.rst b/doc/configuration.rst index 0535ae97..ba0f5040 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -1849,8 +1849,10 @@ they are not scratch builds). A value for ``yum_repourls`` will be created automatically and point at a repository in the current compose. You can add extra repositories with ``repo`` key having a list of urls pointing to ``.repo`` files or just - variant uid, Pungi will create the .repo file for that variant. ``gpgkey`` - can be specified to enable gpgcheck in repo files for variants. + variant uid, Pungi will create the .repo file for that variant. If + specific URL is used in the ``repo``, the ``$COMPOSE_ID`` variable in + the ``repo`` string will be replaced with the real compose ID. + ``gpgkey`` can be specified to enable gpgcheck in repo files for variants. **osbs_registries** (*dict*) -- It is possible to configure extra information about where to diff --git a/pungi/phases/osbs.py b/pungi/phases/osbs.py index 411f05a7..4f4a2980 100644 --- a/pungi/phases/osbs.py +++ b/pungi/phases/osbs.py @@ -128,7 +128,7 @@ class OSBSThread(WorkerThread): file pointing to that location and return the URL to .repo file. """ if "://" in repo: - return repo + return repo.replace("$COMPOSE_ID", compose.compose_id) if repo.startswith("/"): # The repo is an absolute path on the filesystem diff --git a/tests/test_osbs_phase.py b/tests/test_osbs_phase.py index 04e98c19..b37fa178 100644 --- a/tests/test_osbs_phase.py +++ b/tests/test_osbs_phase.py @@ -330,7 +330,12 @@ class OSBSThreadTest(helpers.PungiTestCase): "git_branch": "f24-docker", "name": "my-name", "version": "1.0", - "repo": ["Everything", "http://pkgs.example.com/my.repo", "/extra/repo"], + "repo": [ + "Everything", + "http://pkgs.example.com/my.repo", + "/extra/repo", + "http://cts.localhost/$COMPOSE_ID/repo", + ], } self.compose.conf["translate_paths"].append(("/extra", "http://example.com")) self._setupMock(KojiWrapper) @@ -347,6 +352,7 @@ class OSBSThreadTest(helpers.PungiTestCase): "http://root/work/global/tmp-Everything/compose-rpms-Everything-1.repo", "http://pkgs.example.com/my.repo", "http://root/work/global/tmp/compose-rpms-local-1.repo", + "http://cts.localhost/%s/repo" % self.compose.compose_id, ], } self._assertCorrectCalls(options)