Separate create and build templates
In order to prevent build templates to render during plugin creation we need to put them into different directories. Change-Id: I439bc7618a43ad07cc73fb69b60d99d725c3f9d0 Closes-Bug: #1655289
This commit is contained in:
parent
6a1ae7f520
commit
fae06cf5aa
|
@ -32,9 +32,14 @@ from fuel_plugin_builder import version_mapping
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_template_path(file_name):
|
||||
return os.path.abspath(join_path(
|
||||
os.path.dirname(__file__), '..', 'templates', file_name))
|
||||
|
||||
|
||||
class BaseBuildPlugin(BaseAction):
|
||||
|
||||
release_tmpl_src_path = None
|
||||
release_tmpl_src_path = get_template_path('base/build/Release.mako')
|
||||
|
||||
@abc.abstractproperty
|
||||
def requires(self):
|
||||
|
@ -109,7 +114,6 @@ class BaseBuildPlugin(BaseAction):
|
|||
utils.exec_piped_cmds(
|
||||
['dpkg-scanpackages -m .', 'gzip -c9 > Packages.gz'],
|
||||
cwd=repo_path)
|
||||
if self.release_tmpl_src_path:
|
||||
release_path = join_path(repo_path, 'Release')
|
||||
utils.render_to_file(
|
||||
self.release_tmpl_src_path,
|
||||
|
@ -147,10 +151,6 @@ class BaseBuildPlugin(BaseAction):
|
|||
class BuildPluginV1(BaseBuildPlugin):
|
||||
|
||||
requires = ['rpm', 'createrepo', 'dpkg-scanpackages']
|
||||
release_tmpl_src_path = os.path.abspath(join_path(
|
||||
os.path.dirname(__file__),
|
||||
'..',
|
||||
'templates/v1/build/Release.mako'))
|
||||
|
||||
@property
|
||||
def result_package_mask(self):
|
||||
|
@ -171,7 +171,7 @@ class BuildPluginV2(BuildPluginV1):
|
|||
|
||||
requires = ['rpmbuild', 'rpm', 'createrepo', 'dpkg-scanpackages']
|
||||
|
||||
rpm_spec_src_path = 'templates/v2/build/plugin_rpm.spec.mako'
|
||||
rpm_spec_src_path = get_template_path('v2/build/plugin_rpm.spec.mako')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(BuildPluginV2, self).__init__(*args, **kwargs)
|
||||
|
@ -186,11 +186,6 @@ class BuildPluginV2(BuildPluginV1):
|
|||
tar_name = '{0}.fp'.format(self.full_name)
|
||||
self.tar_path = join_path(self.rpm_src_path, tar_name)
|
||||
|
||||
fpb_dir = join_path(os.path.dirname(__file__), '..')
|
||||
|
||||
self.spec_src = os.path.abspath(join_path(
|
||||
fpb_dir, self.rpm_spec_src_path))
|
||||
|
||||
self.spec_dst = join_path(self.rpm_path, 'plugin_rpm.spec')
|
||||
|
||||
self.rpm_packages_mask = join_path(
|
||||
|
@ -208,7 +203,7 @@ class BuildPluginV2(BuildPluginV1):
|
|||
|
||||
utils.make_tar_gz(self.build_src_dir, self.tar_path, self.full_name)
|
||||
utils.render_to_file(
|
||||
self.spec_src,
|
||||
self.rpm_spec_src_path,
|
||||
self.spec_dst,
|
||||
self._make_data_for_template())
|
||||
|
||||
|
@ -235,7 +230,7 @@ class BuildPluginV2(BuildPluginV1):
|
|||
|
||||
class BuildPluginV3(BuildPluginV2):
|
||||
|
||||
rpm_spec_src_path = 'templates/v3/build/plugin_rpm.spec.mako'
|
||||
rpm_spec_src_path = get_template_path('v3/build/plugin_rpm.spec.mako')
|
||||
|
||||
def _make_data_for_template(self):
|
||||
data = super(BuildPluginV3, self)._make_data_for_template()
|
||||
|
|
|
@ -31,7 +31,7 @@ class TestVersionMapping(BaseTestCase):
|
|||
self.assertEqual(result['version'], '1.0.0')
|
||||
self.assertEqual(
|
||||
result['templates'],
|
||||
['templates/base', 'templates/v1/'])
|
||||
['templates/base/plugin_data', 'templates/v1/plugin_data/'])
|
||||
self.assertEqual(result['validator'], ValidatorV1)
|
||||
|
||||
def test_get_plugin_for_version_2(self):
|
||||
|
@ -39,7 +39,7 @@ class TestVersionMapping(BaseTestCase):
|
|||
self.assertEqual(result['version'], '2.0.0')
|
||||
self.assertEqual(
|
||||
result['templates'],
|
||||
['templates/base', 'templates/v2/plugin_data/'])
|
||||
['templates/base/plugin_data', 'templates/v2/plugin_data/'])
|
||||
self.assertEqual(result['validator'], ValidatorV2)
|
||||
|
||||
def test_get_plugin_for_version_3(self):
|
||||
|
@ -47,7 +47,7 @@ class TestVersionMapping(BaseTestCase):
|
|||
self.assertEqual(result['version'], '3.0.0')
|
||||
self.assertEqual(
|
||||
result['templates'],
|
||||
['templates/base', 'templates/v3/plugin_data/'])
|
||||
['templates/base/plugin_data', 'templates/v3/plugin_data/'])
|
||||
self.assertEqual(result['validator'], ValidatorV3)
|
||||
|
||||
def test_get_plugin_for_version_4(self):
|
||||
|
@ -56,7 +56,7 @@ class TestVersionMapping(BaseTestCase):
|
|||
self.assertEqual(
|
||||
result['templates'],
|
||||
[
|
||||
'templates/base',
|
||||
'templates/base/plugin_data',
|
||||
'templates/v3/plugin_data/',
|
||||
'templates/v4/plugin_data/'])
|
||||
self.assertEqual(result['validator'], ValidatorV4)
|
||||
|
@ -67,7 +67,7 @@ class TestVersionMapping(BaseTestCase):
|
|||
self.assertEqual(
|
||||
result['templates'],
|
||||
[
|
||||
'templates/base',
|
||||
'templates/base/plugin_data',
|
||||
'templates/v3/plugin_data/',
|
||||
'templates/v4/plugin_data/',
|
||||
'templates/v5/plugin_data/'])
|
||||
|
|
|
@ -30,27 +30,30 @@ def get_mapping():
|
|||
|
||||
return [
|
||||
{'version': '1.0.0',
|
||||
'templates': ['templates/base', 'templates/v1/'],
|
||||
'templates': ['templates/base/plugin_data',
|
||||
'templates/v1/plugin_data/'],
|
||||
'validator': validators.ValidatorV1,
|
||||
'builder': build.BuildPluginV1},
|
||||
{'version': '2.0.0',
|
||||
'templates': ['templates/base', 'templates/v2/plugin_data/'],
|
||||
'templates': ['templates/base/plugin_data',
|
||||
'templates/v2/plugin_data/'],
|
||||
'validator': validators.ValidatorV2,
|
||||
'builder': build.BuildPluginV2},
|
||||
{'version': '3.0.0',
|
||||
'templates': ['templates/base', 'templates/v3/plugin_data/'],
|
||||
'templates': ['templates/base/plugin_data',
|
||||
'templates/v3/plugin_data/'],
|
||||
'validator': validators.ValidatorV3,
|
||||
'builder': build.BuildPluginV3},
|
||||
{'version': '4.0.0',
|
||||
'templates': [
|
||||
'templates/base',
|
||||
'templates/base/plugin_data',
|
||||
'templates/v3/plugin_data/',
|
||||
'templates/v4/plugin_data/'],
|
||||
'validator': validators.ValidatorV4,
|
||||
'builder': build.BuildPluginV4},
|
||||
{'version': '5.0.0',
|
||||
'templates': [
|
||||
'templates/base',
|
||||
'templates/base/plugin_data',
|
||||
'templates/v3/plugin_data/',
|
||||
'templates/v4/plugin_data/',
|
||||
'templates/v5/plugin_data/'],
|
||||
|
|
Loading…
Reference in New Issue