2019-03-18 08:07:19 +01:00
|
|
|
# pylint: disable=no-value-for-parameter
|
|
|
|
|
2019-11-08 06:28:46 +01:00
|
|
|
import sys
|
|
|
|
import logging
|
2018-11-15 04:09:57 +01:00
|
|
|
import click
|
|
|
|
from utils.misc import delfile
|
|
|
|
from utils.configs import validate, parse_yaml_config
|
2019-04-02 14:08:26 +02:00
|
|
|
from utils.cert import prepare_ca, SSL_CERT_KEY_PATH, SSL_CERT_PATH, get_secret_key
|
2018-11-15 04:09:57 +01:00
|
|
|
from utils.db import prepare_db
|
|
|
|
from utils.jobservice import prepare_job_service
|
|
|
|
from utils.registry import prepare_registry
|
|
|
|
from utils.registry_ctl import prepare_registry_ctl
|
|
|
|
from utils.core import prepare_core
|
|
|
|
from utils.notary import prepare_notary
|
|
|
|
from utils.log import prepare_log_configs
|
|
|
|
from utils.clair import prepare_clair
|
2019-10-17 06:00:51 +02:00
|
|
|
from utils.clair_adapter import prepare_clair_adapter
|
2018-11-15 04:09:57 +01:00
|
|
|
from utils.chart import prepare_chartmuseum
|
|
|
|
from utils.docker_compose import prepare_docker_compose
|
|
|
|
from utils.nginx import prepare_nginx, nginx_confd_dir
|
2019-07-30 07:04:28 +02:00
|
|
|
from utils.redis import prepare_redis
|
2019-04-02 14:08:26 +02:00
|
|
|
from g import (config_dir, input_config_path, private_key_pem_path, root_crt_path, secret_key_dir,
|
2019-03-18 03:14:00 +01:00
|
|
|
old_private_key_pem_path, old_crt_path)
|
2018-11-15 04:09:57 +01:00
|
|
|
|
|
|
|
# Main function
|
|
|
|
@click.command()
|
2019-04-02 14:08:26 +02:00
|
|
|
@click.option('--conf', default=input_config_path, help="the path of Harbor configuration file")
|
2018-11-15 04:09:57 +01:00
|
|
|
@click.option('--with-notary', is_flag=True, help="the Harbor instance is to be deployed with notary")
|
|
|
|
@click.option('--with-clair', is_flag=True, help="the Harbor instance is to be deployed with clair")
|
|
|
|
@click.option('--with-chartmuseum', is_flag=True, help="the Harbor instance is to be deployed with chart repository supporting")
|
|
|
|
def main(conf, with_notary, with_clair, with_chartmuseum):
|
|
|
|
|
|
|
|
delfile(config_dir)
|
2019-09-03 06:45:46 +02:00
|
|
|
config_dict = parse_yaml_config(conf, with_notary=with_notary, with_clair=with_clair, with_chartmuseum=with_chartmuseum)
|
2019-10-23 08:08:15 +02:00
|
|
|
try:
|
|
|
|
validate(config_dict, notary_mode=with_notary)
|
|
|
|
except Exception as e:
|
2019-12-25 07:59:47 +01:00
|
|
|
logging.info('Error happened in config validation...')
|
2019-11-08 06:28:46 +01:00
|
|
|
logging.error(e)
|
|
|
|
sys.exit(-1)
|
2018-11-15 04:09:57 +01:00
|
|
|
|
|
|
|
prepare_log_configs(config_dict)
|
|
|
|
prepare_nginx(config_dict)
|
2019-02-20 11:01:48 +01:00
|
|
|
prepare_core(config_dict, with_notary=with_notary, with_clair=with_clair, with_chartmuseum=with_chartmuseum)
|
2018-11-15 04:09:57 +01:00
|
|
|
prepare_registry(config_dict)
|
|
|
|
prepare_registry_ctl(config_dict)
|
|
|
|
prepare_db(config_dict)
|
|
|
|
prepare_job_service(config_dict)
|
2019-07-30 07:04:28 +02:00
|
|
|
prepare_redis(config_dict)
|
2018-11-15 04:09:57 +01:00
|
|
|
|
2019-03-12 12:09:01 +01:00
|
|
|
get_secret_key(secret_key_dir)
|
|
|
|
|
2018-11-15 04:09:57 +01:00
|
|
|
# If Customized cert enabled
|
|
|
|
prepare_ca(
|
2019-03-12 12:09:01 +01:00
|
|
|
private_key_pem_path=private_key_pem_path,
|
|
|
|
root_crt_path=root_crt_path,
|
2019-03-18 03:14:00 +01:00
|
|
|
old_private_key_pem_path=old_private_key_pem_path,
|
2019-04-02 14:08:26 +02:00
|
|
|
old_crt_path=old_crt_path)
|
2018-11-15 04:09:57 +01:00
|
|
|
if with_notary:
|
|
|
|
prepare_notary(config_dict, nginx_confd_dir, SSL_CERT_PATH, SSL_CERT_KEY_PATH)
|
|
|
|
|
|
|
|
if with_clair:
|
|
|
|
prepare_clair(config_dict)
|
2019-10-17 06:00:51 +02:00
|
|
|
prepare_clair_adapter(config_dict)
|
2018-11-15 04:09:57 +01:00
|
|
|
|
|
|
|
if with_chartmuseum:
|
|
|
|
prepare_chartmuseum(config_dict)
|
|
|
|
|
|
|
|
prepare_docker_compose(config_dict, with_clair, with_notary, with_chartmuseum)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|