[image-build] Allow dynamic release for images
When the release is explicitly set to None, generate a value from date and respin. The documentation is updated to explain how it works. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
39ce2556c3
commit
dc4d502f2a
|
@ -660,10 +660,13 @@ Image Build Settings
|
||||||
Config can contain anything what is accepted by
|
Config can contain anything what is accepted by
|
||||||
``koji image-build --config configfile.ini``
|
``koji image-build --config configfile.ini``
|
||||||
|
|
||||||
Repo can be specified either as a string or a list of strings. It will
|
Repo can be specified either as a string or a list of strings. It will be
|
||||||
automatically transformed into format suitable for ``koji``. A repo for the
|
automatically transformed into format suitable for ``koji``. A repo for the
|
||||||
currently built variant will be added as well.
|
currently built variant will be added as well.
|
||||||
|
|
||||||
|
If you explicitly set ``release`` to ``None``, it will be replaced with
|
||||||
|
``DATE.RESPIN`` of the current compose.
|
||||||
|
|
||||||
You can also add extra variants to get repos from with key ``repo_from``.
|
You can also add extra variants to get repos from with key ``repo_from``.
|
||||||
The value should be a list of variant names.
|
The value should be a list of variant names.
|
||||||
|
|
||||||
|
@ -698,7 +701,7 @@ Example
|
||||||
'disk_size': 3,
|
'disk_size': 3,
|
||||||
|
|
||||||
# this is set automatically by pungi to os_dir for given variant
|
# this is set automatically by pungi to os_dir for given variant
|
||||||
# 'install_tree': 'http://sometpath',
|
# 'install_tree': 'http://somepath',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'format': [('qcow2','qcow2')]
|
'format': [('qcow2','qcow2')]
|
||||||
|
@ -716,6 +719,9 @@ Example
|
||||||
# Use install tree and repo from Everything variant.
|
# Use install tree and repo from Everything variant.
|
||||||
'install_tree_from': 'Everything',
|
'install_tree_from': 'Everything',
|
||||||
'repo_from': ['Everything'],
|
'repo_from': ['Everything'],
|
||||||
|
|
||||||
|
# Set release based on date and respin.
|
||||||
|
'release': None,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,11 @@ class ImageBuildPhase(PhaseBase):
|
||||||
arches = set(image_conf.get('arches', [])) & arches
|
arches = set(image_conf.get('arches', [])) & arches
|
||||||
return ','.join(sorted(arches))
|
return ','.join(sorted(arches))
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
for variant in self.compose.get_variants():
|
for variant in self.compose.get_variants():
|
||||||
arches = set([x for x in variant.arches if x != 'src'])
|
arches = set([x for x in variant.arches if x != 'src'])
|
||||||
|
@ -101,6 +106,8 @@ class ImageBuildPhase(PhaseBase):
|
||||||
|
|
||||||
image_conf["install_tree"] = self._get_install_tree(image_conf, variant)
|
image_conf["install_tree"] = self._get_install_tree(image_conf, variant)
|
||||||
|
|
||||||
|
self._set_release(image_conf)
|
||||||
|
|
||||||
# transform format into right 'format' for image-build
|
# transform format into right 'format' for image-build
|
||||||
# e.g. 'docker,qcow2'
|
# e.g. 'docker,qcow2'
|
||||||
format = image_conf["format"]
|
format = image_conf["format"]
|
||||||
|
|
|
@ -282,6 +282,40 @@ class TestImageBuildPhase(unittest.TestCase):
|
||||||
"link_type": 'hardlink-or-copy',
|
"link_type": 'hardlink-or-copy',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@mock.patch('pungi.phases.image_build.ThreadPool')
|
||||||
|
def test_image_build_create_release(self, ThreadPool):
|
||||||
|
compose = _DummyCompose({
|
||||||
|
'image_build': {
|
||||||
|
'^Server$': [
|
||||||
|
{
|
||||||
|
'format': [('docker', 'tar.xz')],
|
||||||
|
'name': 'Fedora-Docker-Base',
|
||||||
|
'target': 'f24',
|
||||||
|
'version': 'Rawhide',
|
||||||
|
'ksurl': 'git://git.fedorahosted.org/git/spin-kickstarts.git',
|
||||||
|
'kickstart': "fedora-docker-base.ks",
|
||||||
|
'distro': 'Fedora-20',
|
||||||
|
'disk_size': 3,
|
||||||
|
'arches': ['x86_64'],
|
||||||
|
'release': None,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
'koji_profile': 'koji',
|
||||||
|
})
|
||||||
|
|
||||||
|
phase = ImageBuildPhase(compose)
|
||||||
|
|
||||||
|
phase.run()
|
||||||
|
|
||||||
|
# assert at least one thread was started
|
||||||
|
self.assertTrue(phase.pool.add.called)
|
||||||
|
|
||||||
|
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('release'),
|
||||||
|
'20151203.0')
|
||||||
|
|
||||||
|
|
||||||
class TestCreateImageBuildThread(unittest.TestCase):
|
class TestCreateImageBuildThread(unittest.TestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue