diff --git a/doc/configuration.rst b/doc/configuration.rst index 2365db19..b956b797 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -1165,6 +1165,14 @@ Image Build Settings ``!RELEASE_FROM_LABEL_DATE_TYPE_RESPIN``, it will be replaced with a value generated as described in :ref:`automatic versioning `. + If you explicitly set ``release`` to + ``!RELEASE_FROM_DATE_RESPIN``, it will be replaced with a value + generated as described in :ref:`automatic versioning `. + + If you explicitly set ``version`` to + ``!VERSION_FROM_VERSION``, it will be replaced with a value + generated as described in :ref:`automatic versioning `. + Please don't set ``install_tree``. This gets automatically set by *pungi* based on current variant. You can use ``install_tree_from`` key to use install tree from another variant. diff --git a/pungi/phases/base.py b/pungi/phases/base.py index 42fc2613..9b0600a8 100644 --- a/pungi/phases/base.py +++ b/pungi/phases/base.py @@ -150,7 +150,11 @@ class ImageConfigMixin(object): Get version from configuration hierarchy or fall back to release version. """ - return self.get_config(cfg, 'version') or self.compose.image_version + return ( + util.version_generator(self.compose, self.get_config(cfg, "version")) + or self.get_config(cfg, "version") + or self.compose.image_version + ) def get_release(self, cfg): """ diff --git a/pungi/util.py b/pungi/util.py index 8bb33ebe..78a9c9be 100644 --- a/pungi/util.py +++ b/pungi/util.py @@ -797,10 +797,14 @@ def version_generator(compose, gen): return '%s.%s' % (compose.image_version, compose.image_release) elif gen == '!RELEASE_FROM_LABEL_DATE_TYPE_RESPIN': return compose.image_release + elif gen == '!RELEASE_FROM_DATE_RESPIN': + return '%s.%s' % (compose.compose_date, compose.compose_respin) elif gen == '!VERSION_FROM_VERSION_DATE_RESPIN': return '%s.%s.%s' % (compose.ci_base.release.version, compose.compose_date, compose.compose_respin) + elif gen == '!VERSION_FROM_VERSION': + return '%s' % (compose.ci_base.release.version) elif gen and gen[0] == '!': raise RuntimeError("Unknown version generator '%s'" % gen) return gen diff --git a/tests/test_util.py b/tests/test_util.py index 3fa34804..739ea9e1 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -655,6 +655,18 @@ class TestVersionGenerator(unittest.TestCase): self.assertEqual(util.version_generator(self.compose, '!VERSION_FROM_VERSION_DATE_RESPIN'), '8.20160101.0') + def test_release_from_date_respin(self): + self.assertEqual( + util.version_generator(self.compose, "!RELEASE_FROM_DATE_RESPIN"), + "20160101.0", + ) + + def test_version_from_version(self): + self.assertEqual( + util.version_generator(self.compose, "!VERSION_FROM_VERSION"), + "8", + ) + class TestTZOffset(unittest.TestCase): @mock.patch('time.daylight', new=False)