Use label to populate image release

When release for an image is specified as explicit `None`, we can
generate the value based on compose label. For example for `Alpha-1.2`
the release would be `1.2` instead of the date based one.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-08-25 15:22:55 +02:00
parent d90dba9312
commit 43fda1e9ef
2 changed files with 24 additions and 2 deletions

View File

@ -344,7 +344,14 @@ class Compose(kobo.log.LoggingBase):
@property
def image_release(self):
"""Generate a value to pass to Koji as image release. This includes
date, compose type and respin."""
"""Generate a value to pass to Koji as image release.
If this compose has a label, the version from it will be used,
otherwise we will create a string with date, compose type and respin.
"""
if self.compose_label:
milestone, release = self.compose_label.split('-')
return release
return '%s%s.%s' % (self.compose_date, self.ci_base.compose.type_suffix,
self.compose_respin)

View File

@ -115,6 +115,7 @@ class ComposeTestCase(unittest.TestCase):
ci.return_value.compose.date = '20160107'
ci.return_value.compose.type = 'nightly'
ci.return_value.compose.type_suffix = '.n'
ci.return_value.compose.label = None
compose = Compose(conf, self.tmp_dir)
@ -127,11 +128,25 @@ class ComposeTestCase(unittest.TestCase):
ci.return_value.compose.date = '20160107'
ci.return_value.compose.type = 'production'
ci.return_value.compose.type_suffix = '.n'
ci.return_value.compose.label = None
compose = Compose(conf, self.tmp_dir)
self.assertEqual(compose.image_release, '20160107.n.2')
@mock.patch('pungi.compose.ComposeInfo')
def test_image_release_from_label(self, ci):
conf = {}
ci.return_value.compose.respin = 2
ci.return_value.compose.date = '20160107'
ci.return_value.compose.type = 'production'
ci.return_value.compose.type_suffix = '.n'
ci.return_value.compose.label = 'Alpha-1.2'
compose = Compose(conf, self.tmp_dir)
self.assertEqual(compose.image_release, '1.2')
@mock.patch('pungi.compose.ComposeInfo')
def test_get_variant_arches_without_filter(self, ci):
conf = ConfigWrapper(