From 3dfebed98e3cf89a3270460e266d53796e3c22da Mon Sep 17 00:00:00 2001 From: Qian Deng Date: Mon, 29 Apr 2019 17:15:21 +0800 Subject: [PATCH] Enhance: Add an empty cert files if not exist To avoid confusion error message Signed-off-by: Qian Deng --- make/harbor.yml | 1 + make/photon/prepare/utils/cert.py | 4 ---- make/photon/prepare/utils/nginx.py | 8 ++++++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/make/harbor.yml b/make/harbor.yml index d992b1993..62b5e6514 100644 --- a/make/harbor.yml +++ b/make/harbor.yml @@ -6,6 +6,7 @@ hostname: reg.mydomain.com # http related config http: + # port for http, default is 80. If https enabled, this port will redirect to https port port: 80 # https related config diff --git a/make/photon/prepare/utils/cert.py b/make/photon/prepare/utils/cert.py index 0c75f615c..b0ebeb0d9 100644 --- a/make/photon/prepare/utils/cert.py +++ b/make/photon/prepare/utils/cert.py @@ -10,10 +10,6 @@ from .misc import generate_random_string SSL_CERT_PATH = os.path.join("/etc/nginx/cert", "server.crt") SSL_CERT_KEY_PATH = os.path.join("/etc/nginx/cert", "server.key") -secret_cert_dir = '/secret/nginx' -secret_cert = '/secret/nginx/server.crt' -secret_cert_key = '/secret/nginx/server.key' - secret_keys_dir = '/secret/keys' def _get_secret(folder, filename, length=16): diff --git a/make/photon/prepare/utils/nginx.py b/make/photon/prepare/utils/nginx.py index 08903263a..144262225 100644 --- a/make/photon/prepare/utils/nginx.py +++ b/make/photon/prepare/utils/nginx.py @@ -1,5 +1,6 @@ import os, shutil from fnmatch import fnmatch +from pathlib import Path from g import config_dir, templates_dir from utils.misc import prepare_config_dir, mark_file @@ -12,6 +13,10 @@ nginx_https_conf_template = os.path.join(templates_dir, "nginx", "nginx.https.co nginx_http_conf_template = os.path.join(templates_dir, "nginx", "nginx.http.conf.jinja") nginx_template_ext_dir = os.path.join(templates_dir, 'nginx', 'ext') +cert_dir = Path(os.path.join(config_dir, "nginx", "cert")) +ssl_cert_key = Path(os.path.join(config_dir, "nginx", "cert", 'server.key')) +ssl_cert_cert = Path(os.path.join(config_dir, "nginx", "cert", 'server.crt')) + CUSTOM_NGINX_LOCATION_FILE_PATTERN_HTTPS = 'harbor.https.*.conf' CUSTOM_NGINX_LOCATION_FILE_PATTERN_HTTP = 'harbor.http.*.conf' @@ -25,6 +30,9 @@ def render_nginx_template(config_dict): ssl_cert=SSL_CERT_PATH, ssl_cert_key=SSL_CERT_KEY_PATH) location_file_pattern = CUSTOM_NGINX_LOCATION_FILE_PATTERN_HTTPS + cert_dir.mkdir(parents=True, exist_ok=True) + ssl_cert_key.touch() + ssl_cert_cert.touch() else: render_jinja( nginx_http_conf_template,