Expand version field during image_build using version_generator
We can specify !VERSION_FROM_VERSION in version field during image_build to expand it to correct release number without any label information. Also implemented !RELEASE_FROM_DATE_RESPIN to provide correct release number. This helps to keep Atomic Host media files name produced by image_build during bodhi updates compose run consistent with nightly run. Fixes: https://pagure.io/pungi/issue/987 Merges: https://pagure.io/pungi/pull-request/995 Signed-off-by: Sinny Kumari <sinny@redhat.com>
This commit is contained in:
parent
d29e56c7d8
commit
1759c1ba80
@ -1165,6 +1165,14 @@ Image Build Settings
|
|||||||
``!RELEASE_FROM_LABEL_DATE_TYPE_RESPIN``, it will be replaced with a value
|
``!RELEASE_FROM_LABEL_DATE_TYPE_RESPIN``, it will be replaced with a value
|
||||||
generated as described in :ref:`automatic versioning <auto-version>`.
|
generated as described in :ref:`automatic versioning <auto-version>`.
|
||||||
|
|
||||||
|
If you explicitly set ``release`` to
|
||||||
|
``!RELEASE_FROM_DATE_RESPIN``, it will be replaced with a value
|
||||||
|
generated as described in :ref:`automatic versioning <auto-version>`.
|
||||||
|
|
||||||
|
If you explicitly set ``version`` to
|
||||||
|
``!VERSION_FROM_VERSION``, it will be replaced with a value
|
||||||
|
generated as described in :ref:`automatic versioning <auto-version>`.
|
||||||
|
|
||||||
Please don't set ``install_tree``. This gets automatically set by *pungi*
|
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
|
based on current variant. You can use ``install_tree_from`` key to use
|
||||||
install tree from another variant.
|
install tree from another variant.
|
||||||
|
@ -150,7 +150,11 @@ class ImageConfigMixin(object):
|
|||||||
Get version from configuration hierarchy or fall back to release
|
Get version from configuration hierarchy or fall back to release
|
||||||
version.
|
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):
|
def get_release(self, cfg):
|
||||||
"""
|
"""
|
||||||
|
@ -797,10 +797,14 @@ def version_generator(compose, gen):
|
|||||||
return '%s.%s' % (compose.image_version, compose.image_release)
|
return '%s.%s' % (compose.image_version, compose.image_release)
|
||||||
elif gen == '!RELEASE_FROM_LABEL_DATE_TYPE_RESPIN':
|
elif gen == '!RELEASE_FROM_LABEL_DATE_TYPE_RESPIN':
|
||||||
return compose.image_release
|
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':
|
elif gen == '!VERSION_FROM_VERSION_DATE_RESPIN':
|
||||||
return '%s.%s.%s' % (compose.ci_base.release.version,
|
return '%s.%s.%s' % (compose.ci_base.release.version,
|
||||||
compose.compose_date,
|
compose.compose_date,
|
||||||
compose.compose_respin)
|
compose.compose_respin)
|
||||||
|
elif gen == '!VERSION_FROM_VERSION':
|
||||||
|
return '%s' % (compose.ci_base.release.version)
|
||||||
elif gen and gen[0] == '!':
|
elif gen and gen[0] == '!':
|
||||||
raise RuntimeError("Unknown version generator '%s'" % gen)
|
raise RuntimeError("Unknown version generator '%s'" % gen)
|
||||||
return gen
|
return gen
|
||||||
|
@ -655,6 +655,18 @@ class TestVersionGenerator(unittest.TestCase):
|
|||||||
self.assertEqual(util.version_generator(self.compose, '!VERSION_FROM_VERSION_DATE_RESPIN'),
|
self.assertEqual(util.version_generator(self.compose, '!VERSION_FROM_VERSION_DATE_RESPIN'),
|
||||||
'8.20160101.0')
|
'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):
|
class TestTZOffset(unittest.TestCase):
|
||||||
@mock.patch('time.daylight', new=False)
|
@mock.patch('time.daylight', new=False)
|
||||||
|
Loading…
Reference in New Issue
Block a user