Enhance: Add an empty cert files if not exist

To avoid confusion error message

Signed-off-by: Qian Deng <dengq@vmware.com>
This commit is contained in:
Qian Deng 2019-04-29 17:15:21 +08:00
parent 6ea0514bb7
commit 3dfebed98e
3 changed files with 9 additions and 4 deletions

View File

@ -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

View File

@ -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):

View File

@ -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,