aboutsummaryrefslogtreecommitdiff
path: root/kolla
diff options
context:
space:
mode:
authorAndriy Kurilin <andr.kurilin@gmail.com>2024-09-17 13:49:32 +0200
committerAndriy Kurilin <andr.kurilin@gmail.com>2025-02-18 09:41:17 +0100
commitcfa266a3a2fd2f29ba48ecb93018197af5510649 (patch)
tree364717d58c985a4db60cd87a2bbbdfb221bec757 /kolla
parent2941ea2c7a89c1852a943aed820a45fd9c4e05b7 (diff)
downloadkolla-cfa266a3a2fd2f29ba48ecb93018197af5510649.tar.gz
kolla-cfa266a3a2fd2f29ba48ecb93018197af5510649.zip
Allow to use configure_user macro for external templates
Commit 79a234239516b94b1b79c7ddafcc4fbe4e3ba155 introduced an ability to build 'in-house'/'not-built-in' projects with Kolla. This commits extends this feature with an ability to use configure_user macro for 'not-built-in' users. The implementation is done the same way as for 'sources', i.e. engine after registers new section structure as soon as it finds unknown '<project>-user' section. In addition, the documentation and CI are extended to cover ``--docker-dir`` option. Change-Id: I690d9f3829083f2493bf286a1c45764b9699219b
Diffstat (limited to 'kolla')
-rw-r--r--kolla/image/kolla_worker.py13
-rw-r--r--kolla/template/methods.py6
2 files changed, 18 insertions, 1 deletions
diff --git a/kolla/image/kolla_worker.py b/kolla/image/kolla_worker.py
index 798c8eaa7..3a78a7f35 100644
--- a/kolla/image/kolla_worker.py
+++ b/kolla/image/kolla_worker.py
@@ -271,6 +271,7 @@ class KollaWorker(object):
return {
'debian_package_install': jinja_methods.debian_package_install,
'handle_repos': jinja_methods.handle_repos,
+ 'raise_error': jinja_methods.raise_error,
}
def get_users(self):
@@ -280,7 +281,17 @@ class KollaWorker(object):
for section in all_sections:
match = re.search('^.*-user$', section)
if match:
- user = self.conf[match.group(0)]
+ cfg_group_name = match.group(0)
+
+ if cfg_group_name not in self.conf._groups:
+ self.conf.register_opts(
+ common_config.get_user_opts(
+ None, None,
+ # cut `-user` suffix
+ group=cfg_group_name[:-5]),
+ group=cfg_group_name
+ )
+ user = self.conf[cfg_group_name]
ret[match.group(0)[:-5]] = {
'uid': user.uid,
'gid': user.gid,
diff --git a/kolla/template/methods.py b/kolla/template/methods.py
index 6747504fa..e9edbfeb0 100644
--- a/kolla/template/methods.py
+++ b/kolla/template/methods.py
@@ -11,6 +11,8 @@
# limitations under the License.
import os
+import typing as t
+
import yaml
from jinja2 import pass_context
@@ -150,3 +152,7 @@ def handle_repos(context, reponames, mode):
commands = "RUN %s" % commands
return commands
+
+
+def raise_error(msg: str) -> t.NoReturn:
+ raise Exception(msg)