2021-08-27 17:54:20 +02:00
|
|
|
import os
|
2018-11-15 04:09:57 +01:00
|
|
|
|
2020-02-11 06:47:55 +01:00
|
|
|
from g import config_dir, templates_dir, DEFAULT_GID, DEFAULT_UID
|
2019-08-01 10:02:08 +02:00
|
|
|
from utils.misc import prepare_dir
|
2018-11-15 04:09:57 +01:00
|
|
|
from utils.jinja import render_jinja
|
|
|
|
|
|
|
|
registryctl_config_dir = os.path.join(config_dir, "registryctl")
|
|
|
|
registryctl_config_template_path = os.path.join(templates_dir, "registryctl", "config.yml.jinja")
|
|
|
|
registryctl_conf = os.path.join(config_dir, "registryctl", "config.yml")
|
|
|
|
registryctl_env_template_path = os.path.join(templates_dir, "registryctl", "env.jinja")
|
|
|
|
registryctl_conf_env = os.path.join(config_dir, "registryctl", "env")
|
|
|
|
|
2020-12-14 04:52:42 +01:00
|
|
|
levels_map = {
|
|
|
|
'debug': 'debug',
|
|
|
|
'info': 'info',
|
|
|
|
'warning': 'warn',
|
|
|
|
'error': 'error',
|
|
|
|
'fatal': 'fatal'
|
|
|
|
}
|
|
|
|
|
2018-11-15 04:09:57 +01:00
|
|
|
def prepare_registry_ctl(config_dict):
|
|
|
|
# prepare dir
|
2020-02-11 06:47:55 +01:00
|
|
|
prepare_dir(registryctl_config_dir)
|
2018-11-15 04:09:57 +01:00
|
|
|
|
2020-02-11 06:47:55 +01:00
|
|
|
# Render Registryctl env
|
2018-11-15 04:09:57 +01:00
|
|
|
render_jinja(
|
|
|
|
registryctl_env_template_path,
|
|
|
|
registryctl_conf_env,
|
|
|
|
**config_dict)
|
|
|
|
|
2020-02-11 06:47:55 +01:00
|
|
|
# Render Registryctl config
|
|
|
|
render_jinja(
|
|
|
|
registryctl_config_template_path,
|
|
|
|
registryctl_conf,
|
|
|
|
uid=DEFAULT_UID,
|
|
|
|
gid=DEFAULT_GID,
|
2020-12-14 04:52:42 +01:00
|
|
|
level=levels_map[config_dict['log_level']],
|
2020-02-11 06:47:55 +01:00
|
|
|
**config_dict)
|