Add compose type to release for images
Move getting of the precomputed value to a single place in Compose class. The value now has format `date[.type_suffix].respin`. Resolves: rhbz#1319924 Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
4afd21952c
commit
ecbf08c6f8
@ -340,3 +340,10 @@ class Compose(kobo.log.LoggingBase):
|
||||
self.failed_deliverables.setdefault(variant_uid, {}).setdefault(arch, []).append(deliverable)
|
||||
return True
|
||||
return False
|
||||
|
||||
@property
|
||||
def image_release(self):
|
||||
"""Generate a value to pass to Koji as image release. This includes
|
||||
date, compose type and respin."""
|
||||
return '%s%s.%s' % (self.compose_date, self.ci_base.compose.type_suffix,
|
||||
self.compose_respin)
|
||||
|
@ -81,7 +81,7 @@ class ImageBuildPhase(PhaseBase):
|
||||
def _set_release(self, image_conf):
|
||||
"""If release is set explicitly to None, replace it with date and respin."""
|
||||
if 'release' in image_conf and image_conf['release'] is None:
|
||||
image_conf['release'] = '%s.%s' % (self.compose.compose_date, self.compose.compose_respin)
|
||||
image_conf['release'] = self.compose.image_release
|
||||
|
||||
def run(self):
|
||||
for variant in self.compose.get_variants():
|
||||
|
@ -113,7 +113,7 @@ class LiveImagesPhase(PhaseBase):
|
||||
def _get_release(self, image_conf):
|
||||
"""If release is set explicitly to None, replace it with date and respin."""
|
||||
if 'release' in image_conf and image_conf['release'] is None:
|
||||
return '%s.%s' % (self.compose.compose_date, self.compose.compose_respin)
|
||||
return self.compose.image_release
|
||||
return image_conf.get('release', None)
|
||||
|
||||
def run(self):
|
||||
|
@ -91,7 +91,7 @@ class LiveMediaPhase(PhaseBase):
|
||||
"""
|
||||
for key, conf in [('release', image_conf), ('live_media_release', self.compose.conf)]:
|
||||
if key in conf and conf[key] is None:
|
||||
return '%s.%s' % (self.compose.compose_date, self.compose.compose_respin)
|
||||
return self.compose.image_release
|
||||
return image_conf.get('release', self.compose.conf.get('live_media_release'))
|
||||
|
||||
def _get_install_tree(self, image_conf, variant):
|
||||
|
@ -26,6 +26,7 @@ class DummyCompose(object):
|
||||
self.compose_respin = 0
|
||||
self.compose_id = 'Test-20151203.0.t'
|
||||
self.compose_label = None
|
||||
self.image_release = '20151203.t.0'
|
||||
self.ci_base = mock.Mock(
|
||||
release_id='Test-1.0',
|
||||
release=mock.Mock(
|
||||
|
@ -99,6 +99,30 @@ class ComposeTestCase(unittest.TestCase):
|
||||
'RC-1.0', '1', 'rel_short', '2', '.iso', 'nightly',
|
||||
'.n', 'Server', '3.0']))
|
||||
|
||||
@mock.patch('pungi.compose.ComposeInfo')
|
||||
def test_image_release(self, ci):
|
||||
conf = {}
|
||||
ci.return_value.compose.respin = 2
|
||||
ci.return_value.compose.date = '20160107'
|
||||
ci.return_value.compose.type = 'nightly'
|
||||
ci.return_value.compose.type_suffix = '.n'
|
||||
|
||||
compose = Compose(conf, self.tmp_dir)
|
||||
|
||||
self.assertEqual(compose.image_release, '20160107.n.2')
|
||||
|
||||
@mock.patch('pungi.compose.ComposeInfo')
|
||||
def test_image_release_production(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'
|
||||
|
||||
compose = Compose(conf, self.tmp_dir)
|
||||
|
||||
self.assertEqual(compose.image_release, '20160107.n.2')
|
||||
|
||||
|
||||
class StatusTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
@ -284,7 +284,7 @@ class TestImageBuildPhase(PungiTestCase):
|
||||
self.assertTrue(phase.pool.queue_put.called_once)
|
||||
args, kwargs = phase.pool.queue_put.call_args
|
||||
self.assertEqual(args[0][1].get('image_conf', {}).get('image-build', {}).get('release'),
|
||||
'20151203.0')
|
||||
'20151203.t.0')
|
||||
|
||||
@mock.patch('pungi.phases.image_build.ThreadPool')
|
||||
def test_image_build_scratch_build(self, ThreadPool):
|
||||
|
@ -54,7 +54,7 @@ class TestLiveImagesPhase(PungiTestCase):
|
||||
'specfile': None,
|
||||
'sign': False,
|
||||
'type': 'live',
|
||||
'release': '20151203.0',
|
||||
'release': '20151203.t.0',
|
||||
'subvariant': 'Client',
|
||||
'ksurl': None},
|
||||
compose.variants['Client'],
|
||||
@ -102,7 +102,7 @@ class TestLiveImagesPhase(PungiTestCase):
|
||||
'specfile': None,
|
||||
'sign': False,
|
||||
'type': 'live',
|
||||
'release': '20151203.0',
|
||||
'release': '20151203.t.0',
|
||||
'subvariant': 'Client',
|
||||
'ksurl': None},
|
||||
compose.variants['Client'],
|
||||
@ -147,7 +147,7 @@ class TestLiveImagesPhase(PungiTestCase):
|
||||
'specfile': None,
|
||||
'sign': False,
|
||||
'type': 'live',
|
||||
'release': '20151203.0',
|
||||
'release': '20151203.t.0',
|
||||
'subvariant': 'Client',
|
||||
'ksurl': None},
|
||||
compose.variants['Client'],
|
||||
@ -309,7 +309,7 @@ class TestLiveImagesPhase(PungiTestCase):
|
||||
'specfile': None,
|
||||
'sign': False,
|
||||
'type': 'live',
|
||||
'release': '20151203.0',
|
||||
'release': '20151203.t.0',
|
||||
'subvariant': 'Client',
|
||||
'ksurl': None},
|
||||
compose.variants['Client'],
|
||||
|
@ -259,7 +259,7 @@ class TestLiveMediaPhase(PungiTestCase):
|
||||
'ksurl': 'resolved',
|
||||
'ksversion': '24',
|
||||
'name': 'Fedora Server Live',
|
||||
'release': '20151203.0',
|
||||
'release': '20151203.t.0',
|
||||
'repo': ['http://example.com/extra_repo',
|
||||
self.topdir + '/compose/Everything/$basearch/os',
|
||||
self.topdir + '/compose/Server/$basearch/os'],
|
||||
|
Loading…
Reference in New Issue
Block a user