mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-18 16:25:16 +01:00
dacb1fc79e
Signed-off-by: Qian Deng <dengq@vmware.com>
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
import os, shutil
|
|
|
|
from g import templates_dir, config_dir, DEFAULT_UID, DEFAULT_GID
|
|
from .jinja import render_jinja
|
|
from .misc import prepare_dir
|
|
|
|
clair_template_dir = os.path.join(templates_dir, "clair")
|
|
|
|
def prepare_clair(config_dict):
|
|
clair_config_dir = prepare_dir(config_dir, "clair")
|
|
|
|
if os.path.exists(os.path.join(clair_config_dir, "postgresql-init.d")):
|
|
print("Copying offline data file for clair DB")
|
|
shutil.rmtree(os.path.join(clair_config_dir, "postgresql-init.d"))
|
|
|
|
shutil.copytree(os.path.join(clair_template_dir, "postgresql-init.d"), os.path.join(clair_config_dir, "postgresql-init.d"))
|
|
|
|
postgres_env_path = os.path.join(clair_config_dir, "postgres_env")
|
|
postgres_env_template = os.path.join(clair_template_dir, "postgres_env.jinja")
|
|
|
|
clair_config_path = os.path.join(clair_config_dir, "config.yaml")
|
|
clair_config_template = os.path.join(clair_template_dir, "config.yaml.jinja")
|
|
|
|
clair_env_path = os.path.join(clair_config_dir, "clair_env")
|
|
clair_env_template = os.path.join(clair_template_dir, "clair_env.jinja")
|
|
|
|
render_jinja(
|
|
postgres_env_template,
|
|
postgres_env_path,
|
|
**config_dict)
|
|
|
|
render_jinja(
|
|
clair_config_template,
|
|
clair_config_path,
|
|
uid=DEFAULT_UID,
|
|
gid=DEFAULT_GID,
|
|
**config_dict)
|
|
|
|
# config http proxy for Clair
|
|
render_jinja(
|
|
clair_env_template,
|
|
clair_env_path,
|
|
**config_dict)
|