| |
@@ -0,0 +1,84 @@
|
| |
+ From a16599c827e475c65dc5709b067283cef37931e1 Mon Sep 17 00:00:00 2001
|
| |
+ From: "Owen W. Taylor" <otaylor@fishsoup.net>
|
| |
+ Date: Thu, 15 Feb 2018 14:32:17 -0500
|
| |
+ Subject: [PATCH] pre_resolve_module_compose.py: Handle change to module
|
| |
+ separator
|
| |
+
|
| |
+ It was officially decided that module versions are formatted as N:V:R not N-V-R.
|
| |
+ ODCS on input accepts either, so keep on passing N-V-R, but we need to accept
|
| |
+ N:V:R if we receive it.
|
| |
+ ---
|
| |
+ atomic_reactor/plugins/pre_resolve_module_compose.py | 7 ++++++-
|
| |
+ tests/plugins/test_resolve_module_compose.py | 11 ++++++-----
|
| |
+ 2 files changed, 12 insertions(+), 6 deletions(-)
|
| |
+
|
| |
+ diff --git a/atomic_reactor/plugins/pre_resolve_module_compose.py b/atomic_reactor/plugins/pre_resolve_module_compose.py
|
| |
+ index f5e076e..3eed644 100644
|
| |
+ --- a/atomic_reactor/plugins/pre_resolve_module_compose.py
|
| |
+ +++ b/atomic_reactor/plugins/pre_resolve_module_compose.py
|
| |
+ @@ -138,6 +138,8 @@ class ResolveModuleComposePlugin(PreBuildPlugin):
|
| |
+ # makes things simpler.
|
| |
+ pdc_client = PDCClient(server=self.pdc_url, ssl_verify=not self.pdc_insecure, develop=True)
|
| |
+
|
| |
+ + # The module separator was changed from '-' to ':'. Older versions of ODCS only accept
|
| |
+ + # '-' as a separator, newer versions accept either. Use '-' for compatibility.
|
| |
+ fmt = '{n}-{s}' if self.module_version is None else '{n}-{s}-{v}'
|
| |
+ source_spec = fmt.format(n=self.module_name, s=self.module_stream, v=self.module_version)
|
| |
+
|
| |
+ @@ -156,7 +158,10 @@ class ResolveModuleComposePlugin(PreBuildPlugin):
|
| |
+ resolved_modules = {}
|
| |
+
|
| |
+ for module_spec in compose_source.strip().split():
|
| |
+ - m = re.match(r'^(.*)-([^-]+)-(\d{14})$', module_spec)
|
| |
+ + m = re.match(r'^(.*):([^-]+):(\d{14})$', module_spec)
|
| |
+ + if not m:
|
| |
+ + # Older versions of ODCS return '-' as the separator
|
| |
+ + m = re.match(r'^(.*)-([^-]+)-(\d{14})$', module_spec)
|
| |
+ if not m:
|
| |
+ raise RuntimeError("Cannot parse resolved module in compose: %s" % module_spec)
|
| |
+
|
| |
+ diff --git a/tests/plugins/test_resolve_module_compose.py b/tests/plugins/test_resolve_module_compose.py
|
| |
+ index 9632165..7d5a0ba 100644
|
| |
+ --- a/tests/plugins/test_resolve_module_compose.py
|
| |
+ +++ b/tests/plugins/test_resolve_module_compose.py
|
| |
+ @@ -88,13 +88,13 @@ LATEST_VERSION_JSON = [{"modulemd": FLATPAK_APP_MODULEMD,
|
| |
+ "rpms": FLATPAK_APP_RPMS}]
|
| |
+
|
| |
+
|
| |
+ -def compose_json(state, state_name):
|
| |
+ +def compose_json(state, state_name, module_version_colon=True):
|
| |
+ return json.dumps({
|
| |
+ "flags": [],
|
| |
+ "id": 84,
|
| |
+ "owner": "Unknown",
|
| |
+ "result_repo": "http://odcs.fedoraproject.org/composes/latest-odcs-84-1/compose/Temporary",
|
| |
+ - "source": MODULE_NSV,
|
| |
+ + "source": MODULE_NSV.replace('-', ':') if module_version_colon else MODULE_NSV,
|
| |
+ "source_type": 2,
|
| |
+ "state": state,
|
| |
+ "state_name": state_name
|
| |
+ @@ -105,7 +105,8 @@ def compose_json(state, state_name):
|
| |
+ @pytest.mark.skipif(not MODULEMD_AVAILABLE,
|
| |
+ reason="modulemd not available")
|
| |
+ @pytest.mark.parametrize('specify_version', [True, False])
|
| |
+ -def test_resolve_module_compose(tmpdir, docker_tasker, specify_version):
|
| |
+ +@pytest.mark.parametrize('module_version_colon', [True, False])
|
| |
+ +def test_resolve_module_compose(tmpdir, docker_tasker, specify_version, module_version_colon):
|
| |
+ secrets_path = os.path.join(str(tmpdir), "secret")
|
| |
+ os.mkdir(secrets_path)
|
| |
+ with open(os.path.join(secrets_path, "token"), "w") as f:
|
| |
+ @@ -139,9 +140,9 @@ def test_resolve_module_compose(tmpdir, docker_tasker, specify_version):
|
| |
+ assert request.headers['Authorization'] == 'Bearer green_eggs_and_ham'
|
| |
+
|
| |
+ if state['count'] == 1:
|
| |
+ - response_json = compose_json(1, 'generating')
|
| |
+ + response_json = compose_json(1, 'generating', module_version_colon=module_version_colon)
|
| |
+ else:
|
| |
+ - response_json = compose_json(2, 'done')
|
| |
+ + response_json = compose_json(2, 'done', module_version_colon=module_version_colon)
|
| |
+ state['count'] += 1
|
| |
+
|
| |
+ return (200, {}, response_json)
|
| |
+ --
|
| |
+ 2.14.3
|
| |
+
|
| |
https://github.com/projectatomic/atomic-reactor/pull/920
https://github.com/projectatomic/atomic-reactor/pull/921
(Note that the current upstream patch for PR#921 is different, because of changes in atomic-reactor master.)