From 3894d734a425b23fc5d36b7126db8ec395bbae72 Mon Sep 17 00:00:00 2001 From: Lubomír Sedlář Date: Jan 29 2019 08:47:57 +0000 Subject: symlink: Add non-ga base product type The same layered product can be built for multiple versions of base product. We don't want colliding symlinks. For backwards compatibility the type is only added when it's not GA. This way it's also similar to how release IDs are generated in productmd. JIRA: RCMWORK-17923 Signed-off-by: Lubomír Sedlář --- diff --git a/compose_utils/symlink.py b/compose_utils/symlink.py index 1c4bdf2..c6467bf 100644 --- a/compose_utils/symlink.py +++ b/compose_utils/symlink.py @@ -48,7 +48,11 @@ class ComposeSymlink(object): fmt = "latest-{0.release.short}-{1}" if self.compose.info.release.is_layered: + # Add info about base product fmt += '-{0.base_product.short}-{0.base_product.version}' + if self.compose.info.base_product.type != "ga": + # Add base product type only if it's not ga + fmt += "-{0.base_product.type}" return fmt.format(self.compose.info, version) def print_latest_link(self, minor_version=None, version_type=VersionType.MAJOR): diff --git a/tests/test_symlink.py b/tests/test_symlink.py index d960c2b..5377458 100644 --- a/tests/test_symlink.py +++ b/tests/test_symlink.py @@ -25,11 +25,11 @@ class TestLatestSymlink(unittest.TestCase): def tearDown(self): shutil.rmtree(self.compose_dir) - def _write_compose(self, is_layered=False): + def _write_compose(self, is_layered=False, base_product_type="ga"): if is_layered: self.compose.info.release.is_layered = True self.compose.info.base_product.name = 'Base Product' - self.compose.info.base_product.type = 'ga' + self.compose.info.base_product.type = base_product_type self.compose.info.base_product.short = 'BP' self.compose.info.base_product.version = '15' @@ -51,6 +51,14 @@ class TestLatestSymlink(unittest.TestCase): self.assertEqual(os.readlink(os.path.join(self.compose_dir, 'latest-DP-1-BP-15')), 'DP-1.0-20160315.t.1') + def test_layered_non_ga_base(self): + path = self._write_compose(is_layered=True, base_product_type="eus") + symlink.create_latest_link(path) + self.assertEqual( + os.readlink(os.path.join(self.compose_dir, "latest-DP-1-BP-15-eus")), + "DP-1.0-20160315.t.1" + ) + def test_with_minor_version(self): path = self._write_compose() with self.assertWarns(DeprecationWarning):