Browse Source

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
changes/80/419880/3
Georgy Kibardin 2 years ago
parent
commit
fae06cf5aa

+ 15
- 20
fuel_plugin_builder/actions/build.py View File

@@ -32,9 +32,14 @@ from fuel_plugin_builder import version_mapping
32 32
 logger = logging.getLogger(__name__)
33 33
 
34 34
 
35
+def get_template_path(file_name):
36
+    return os.path.abspath(join_path(
37
+        os.path.dirname(__file__), '..', 'templates', file_name))
38
+
39
+
35 40
 class BaseBuildPlugin(BaseAction):
36 41
 
37
-    release_tmpl_src_path = None
42
+    release_tmpl_src_path = get_template_path('base/build/Release.mako')
38 43
 
39 44
     @abc.abstractproperty
40 45
     def requires(self):
@@ -109,13 +114,12 @@ class BaseBuildPlugin(BaseAction):
109 114
             utils.exec_piped_cmds(
110 115
                 ['dpkg-scanpackages -m .', 'gzip -c9 > Packages.gz'],
111 116
                 cwd=repo_path)
112
-            if self.release_tmpl_src_path:
113
-                release_path = join_path(repo_path, 'Release')
114
-                utils.render_to_file(
115
-                    self.release_tmpl_src_path,
116
-                    release_path,
117
-                    {'plugin_name': self.meta['name'],
118
-                     'major_version': self.plugin_version})
117
+            release_path = join_path(repo_path, 'Release')
118
+            utils.render_to_file(
119
+                self.release_tmpl_src_path,
120
+                release_path,
121
+                {'plugin_name': self.meta['name'],
122
+                    'major_version': self.plugin_version})
119 123
 
120 124
     @classmethod
121 125
     def build_centos_repos(cls, releases_paths):
@@ -147,10 +151,6 @@ class BaseBuildPlugin(BaseAction):
147 151
 class BuildPluginV1(BaseBuildPlugin):
148 152
 
149 153
     requires = ['rpm', 'createrepo', 'dpkg-scanpackages']
150
-    release_tmpl_src_path = os.path.abspath(join_path(
151
-        os.path.dirname(__file__),
152
-        '..',
153
-        'templates/v1/build/Release.mako'))
154 154
 
155 155
     @property
156 156
     def result_package_mask(self):
@@ -171,7 +171,7 @@ class BuildPluginV2(BuildPluginV1):
171 171
 
172 172
     requires = ['rpmbuild', 'rpm', 'createrepo', 'dpkg-scanpackages']
173 173
 
174
-    rpm_spec_src_path = 'templates/v2/build/plugin_rpm.spec.mako'
174
+    rpm_spec_src_path = get_template_path('v2/build/plugin_rpm.spec.mako')
175 175
 
176 176
     def __init__(self, *args, **kwargs):
177 177
         super(BuildPluginV2, self).__init__(*args, **kwargs)
@@ -186,11 +186,6 @@ class BuildPluginV2(BuildPluginV1):
186 186
         tar_name = '{0}.fp'.format(self.full_name)
187 187
         self.tar_path = join_path(self.rpm_src_path, tar_name)
188 188
 
189
-        fpb_dir = join_path(os.path.dirname(__file__), '..')
190
-
191
-        self.spec_src = os.path.abspath(join_path(
192
-            fpb_dir, self.rpm_spec_src_path))
193
-
194 189
         self.spec_dst = join_path(self.rpm_path, 'plugin_rpm.spec')
195 190
 
196 191
         self.rpm_packages_mask = join_path(
@@ -208,7 +203,7 @@ class BuildPluginV2(BuildPluginV1):
208 203
 
209 204
         utils.make_tar_gz(self.build_src_dir, self.tar_path, self.full_name)
210 205
         utils.render_to_file(
211
-            self.spec_src,
206
+            self.rpm_spec_src_path,
212 207
             self.spec_dst,
213 208
             self._make_data_for_template())
214 209
 
@@ -235,7 +230,7 @@ class BuildPluginV2(BuildPluginV1):
235 230
 
236 231
 class BuildPluginV3(BuildPluginV2):
237 232
 
238
-    rpm_spec_src_path = 'templates/v3/build/plugin_rpm.spec.mako'
233
+    rpm_spec_src_path = get_template_path('v3/build/plugin_rpm.spec.mako')
239 234
 
240 235
     def _make_data_for_template(self):
241 236
         data = super(BuildPluginV3, self)._make_data_for_template()

fuel_plugin_builder/templates/v1/build/Release.mako → fuel_plugin_builder/templates/base/build/Release.mako View File


fuel_plugin_builder/templates/base/LICENSE → fuel_plugin_builder/templates/base/plugin_data/LICENSE View File


fuel_plugin_builder/templates/base/README.md.mako → fuel_plugin_builder/templates/base/plugin_data/README.md.mako View File


fuel_plugin_builder/templates/base/deployment_scripts/deploy.sh.mako → fuel_plugin_builder/templates/base/plugin_data/deployment_scripts/deploy.sh.mako View File


fuel_plugin_builder/templates/base/environment_config.yaml.mako → fuel_plugin_builder/templates/base/plugin_data/environment_config.yaml.mako View File


fuel_plugin_builder/templates/base/pre_build_hook → fuel_plugin_builder/templates/base/plugin_data/pre_build_hook View File


fuel_plugin_builder/templates/base/repositories/centos/.gitkeep → fuel_plugin_builder/templates/base/plugin_data/repositories/centos/.gitkeep View File


fuel_plugin_builder/templates/base/repositories/ubuntu/.gitkeep → fuel_plugin_builder/templates/base/plugin_data/repositories/ubuntu/.gitkeep View File


fuel_plugin_builder/templates/v1/metadata.yaml.mako → fuel_plugin_builder/templates/v1/plugin_data/metadata.yaml.mako View File


fuel_plugin_builder/templates/v1/tasks.yaml → fuel_plugin_builder/templates/v1/plugin_data/tasks.yaml View File


+ 5
- 5
fuel_plugin_builder/tests/test_version_mapping.py View File

@@ -31,7 +31,7 @@ class TestVersionMapping(BaseTestCase):
31 31
         self.assertEqual(result['version'], '1.0.0')
32 32
         self.assertEqual(
33 33
             result['templates'],
34
-            ['templates/base', 'templates/v1/'])
34
+            ['templates/base/plugin_data', 'templates/v1/plugin_data/'])
35 35
         self.assertEqual(result['validator'], ValidatorV1)
36 36
 
37 37
     def test_get_plugin_for_version_2(self):
@@ -39,7 +39,7 @@ class TestVersionMapping(BaseTestCase):
39 39
         self.assertEqual(result['version'], '2.0.0')
40 40
         self.assertEqual(
41 41
             result['templates'],
42
-            ['templates/base', 'templates/v2/plugin_data/'])
42
+            ['templates/base/plugin_data', 'templates/v2/plugin_data/'])
43 43
         self.assertEqual(result['validator'], ValidatorV2)
44 44
 
45 45
     def test_get_plugin_for_version_3(self):
@@ -47,7 +47,7 @@ class TestVersionMapping(BaseTestCase):
47 47
         self.assertEqual(result['version'], '3.0.0')
48 48
         self.assertEqual(
49 49
             result['templates'],
50
-            ['templates/base', 'templates/v3/plugin_data/'])
50
+            ['templates/base/plugin_data', 'templates/v3/plugin_data/'])
51 51
         self.assertEqual(result['validator'], ValidatorV3)
52 52
 
53 53
     def test_get_plugin_for_version_4(self):
@@ -56,7 +56,7 @@ class TestVersionMapping(BaseTestCase):
56 56
         self.assertEqual(
57 57
             result['templates'],
58 58
             [
59
-                'templates/base',
59
+                'templates/base/plugin_data',
60 60
                 'templates/v3/plugin_data/',
61 61
                 'templates/v4/plugin_data/'])
62 62
         self.assertEqual(result['validator'], ValidatorV4)
@@ -67,7 +67,7 @@ class TestVersionMapping(BaseTestCase):
67 67
         self.assertEqual(
68 68
             result['templates'],
69 69
             [
70
-                'templates/base',
70
+                'templates/base/plugin_data',
71 71
                 'templates/v3/plugin_data/',
72 72
                 'templates/v4/plugin_data/',
73 73
                 'templates/v5/plugin_data/'])

+ 8
- 5
fuel_plugin_builder/version_mapping.py View File

@@ -30,27 +30,30 @@ def get_mapping():
30 30
 
31 31
     return [
32 32
         {'version': '1.0.0',
33
-         'templates': ['templates/base', 'templates/v1/'],
33
+         'templates': ['templates/base/plugin_data',
34
+                       'templates/v1/plugin_data/'],
34 35
          'validator': validators.ValidatorV1,
35 36
          'builder': build.BuildPluginV1},
36 37
         {'version': '2.0.0',
37
-         'templates': ['templates/base', 'templates/v2/plugin_data/'],
38
+         'templates': ['templates/base/plugin_data',
39
+                       'templates/v2/plugin_data/'],
38 40
          'validator': validators.ValidatorV2,
39 41
          'builder': build.BuildPluginV2},
40 42
         {'version': '3.0.0',
41
-         'templates': ['templates/base', 'templates/v3/plugin_data/'],
43
+         'templates': ['templates/base/plugin_data',
44
+                       'templates/v3/plugin_data/'],
42 45
          'validator': validators.ValidatorV3,
43 46
          'builder': build.BuildPluginV3},
44 47
         {'version': '4.0.0',
45 48
          'templates': [
46
-             'templates/base',
49
+             'templates/base/plugin_data',
47 50
              'templates/v3/plugin_data/',
48 51
              'templates/v4/plugin_data/'],
49 52
          'validator': validators.ValidatorV4,
50 53
          'builder': build.BuildPluginV4},
51 54
         {'version': '5.0.0',
52 55
          'templates': [
53
-             'templates/base',
56
+             'templates/base/plugin_data',
54 57
              'templates/v3/plugin_data/',
55 58
              'templates/v4/plugin_data/',
56 59
              'templates/v5/plugin_data/'],

Loading…
Cancel
Save