mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-05 10:10:12 +01:00
ab7c81dac6
Remove some code related to adminserver Fix some issues by adminserver removeing Signed-off-by: Qian Deng <dengq@vmware.com>
56 lines
2.0 KiB
Python
56 lines
2.0 KiB
Python
import shutil, os
|
|
|
|
from g import config_dir, templates_dir
|
|
from utils.misc import prepare_config_dir, generate_random_string
|
|
from utils.jinja import render_jinja
|
|
|
|
core_config_dir = os.path.join(config_dir, "core", "certificates")
|
|
core_env_template_path = os.path.join(templates_dir, "core", "env.jinja")
|
|
core_conf_env = os.path.join(config_dir, "core", "env")
|
|
core_conf_template_path = os.path.join(templates_dir, "core", "app.conf.jinja")
|
|
core_conf = os.path.join(config_dir, "core", "app.conf")
|
|
|
|
core_config_env_template = os.path.join(templates_dir, "core", "config_env.jinja")
|
|
core_config_env = os.path.join(config_dir, "core", "config_env")
|
|
|
|
def prepare_core(config_dict, with_notary, with_clair, with_chartmuseum):
|
|
prepare_core_config_dir()
|
|
# Render Core
|
|
# set cache for chart repo server
|
|
# default set 'memory' mode, if redis is configured then set to 'redis'
|
|
if len(config_dict['redis_host']) > 0:
|
|
chart_cache_driver = "redis"
|
|
else:
|
|
chart_cache_driver = "memory"
|
|
|
|
render_config_env(config_dict, with_notary, with_clair, with_chartmuseum)
|
|
|
|
render_jinja(
|
|
core_env_template_path,
|
|
core_conf_env,
|
|
chart_cache_driver=chart_cache_driver,
|
|
**config_dict)
|
|
|
|
# Copy Core app.conf
|
|
copy_core_config(core_conf_template_path, core_conf)
|
|
|
|
def prepare_core_config_dir():
|
|
prepare_config_dir(core_config_dir)
|
|
|
|
def copy_core_config(core_templates_path, core_config_path):
|
|
shutil.copyfile(core_templates_path, core_config_path)
|
|
print("Generated configuration file: %s" % core_config_path)
|
|
|
|
def render_config_env(config_dict, with_notary, with_clair, with_chartmuseum):
|
|
# Use reload_key to avoid reload config after restart harbor
|
|
reload_key = generate_random_string(6) if config_dict['reload_config'] == "true" else ""
|
|
|
|
render_jinja(
|
|
core_config_env_template,
|
|
core_config_env,
|
|
with_notary=with_notary,
|
|
with_clair=with_clair,
|
|
with_chartmuseum=with_chartmuseum,
|
|
reload_key=reload_key,
|
|
**config_dict
|
|
) |