From 412112e5e0155dc2725b855fd5c9069d8b397839 Mon Sep 17 00:00:00 2001 From: Robert Cerven Date: Wed, 12 Jul 2023 22:41:32 +0200 Subject: [PATCH] convert binary build git url to https url with 'git' in path based on a option * STONEBLD-1497 Signed-off-by: Robert Cerven --- atomic_reactor/plugins/fetch_sources.py | 13 +++++++++++++ atomic_reactor/schemas/config.json | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/atomic_reactor/plugins/fetch_sources.py b/atomic_reactor/plugins/fetch_sources.py index d41780edc..a55acf75d 100644 --- a/atomic_reactor/plugins/fetch_sources.py +++ b/atomic_reactor/plugins/fetch_sources.py @@ -27,6 +27,11 @@ from atomic_reactor.download import download_url from atomic_reactor.utils.pnc import PNCUtil +try: + from urlparse import urlparse +except ImportError: + from urllib.parse import urlparse + class FetchSourcesPlugin(Plugin): """Download sources that may be used in further steps to compose Source Containers""" @@ -201,8 +206,16 @@ def _get_cache_allowlist(self) -> List[Dict[str, Any]]: def check_lookaside_cache_usage(self): """Check usage of lookaside cache, and fail if used""" + src_config = self.workflow.conf.source_container + rh_git_url = src_config.get('rh_git_url') git_uri, git_commit = self.koji_build['source'].split('#') + if rh_git_url: + parsed = urlparse(git_uri) + if parsed.scheme == 'git': + new_path = '/git' + parsed.path + git_uri = parsed._replace(path=new_path, scheme='https').geturl() + source = GitSource('git', git_uri, provider_params={'git_commit': git_commit}) source_path = source.get() sources_cache_file = os.path.join(source_path, 'sources') diff --git a/atomic_reactor/schemas/config.json b/atomic_reactor/schemas/config.json index 181b14d67..472f46d1d 100644 --- a/atomic_reactor/schemas/config.json +++ b/atomic_reactor/schemas/config.json @@ -606,6 +606,11 @@ "description": "Openshift memory request for build", "type": "string", "examples": ["1Gi", "3Gi"] + }, + "rh_git_url": { + "description": "Convert binary build git url to RH one", + "type": "boolean", + "default": false } }, "additionalProperties": false