mirror of
https://github.com/goharbor/harbor
synced 2025-04-24 20:20:24 +00:00
parent
5076897ea9
commit
691bdd511d
@ -7,7 +7,7 @@ import string
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
import commands
|
import subprocess
|
||||||
from io import open
|
from io import open
|
||||||
|
|
||||||
if sys.version_info[:3][0] == 2:
|
if sys.version_info[:3][0] == 2:
|
||||||
@ -18,6 +18,10 @@ if sys.version_info[:3][0] == 3:
|
|||||||
import configparser as ConfigParser
|
import configparser as ConfigParser
|
||||||
import io as StringIO
|
import io as StringIO
|
||||||
|
|
||||||
|
def validate(conf):
|
||||||
|
if len(conf.get("configuration", "secret_key")) != 16:
|
||||||
|
raise Exception("Error: The length of secret key has to be 16 characters!")
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('-conf', dest='cfgfile', default = 'harbor.cfg',type=str,help="the path of Harbor configuration file")
|
parser.add_argument('-conf', dest='cfgfile', default = 'harbor.cfg',type=str,help="the path of Harbor configuration file")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@ -30,6 +34,8 @@ conf.seek(0, os.SEEK_SET)
|
|||||||
rcp = ConfigParser.RawConfigParser()
|
rcp = ConfigParser.RawConfigParser()
|
||||||
rcp.readfp(conf)
|
rcp.readfp(conf)
|
||||||
|
|
||||||
|
validate(rcp)
|
||||||
|
|
||||||
hostname = rcp.get("configuration", "hostname")
|
hostname = rcp.get("configuration", "hostname")
|
||||||
ui_url = rcp.get("configuration", "ui_url_protocol") + "://" + hostname
|
ui_url = rcp.get("configuration", "ui_url_protocol") + "://" + hostname
|
||||||
email_server = rcp.get("configuration", "email_server")
|
email_server = rcp.get("configuration", "email_server")
|
||||||
@ -56,14 +62,14 @@ crt_email = rcp.get("configuration", "crt_email")
|
|||||||
max_job_workers = rcp.get("configuration", "max_job_workers")
|
max_job_workers = rcp.get("configuration", "max_job_workers")
|
||||||
token_expiration = rcp.get("configuration", "token_expiration")
|
token_expiration = rcp.get("configuration", "token_expiration")
|
||||||
verify_remote_cert = rcp.get("configuration", "verify_remote_cert")
|
verify_remote_cert = rcp.get("configuration", "verify_remote_cert")
|
||||||
|
secret_key = rcp.get("configuration", "secret_key")
|
||||||
########
|
########
|
||||||
|
|
||||||
#Read version form .git
|
#Read version form .git
|
||||||
status, output = commands.getstatusoutput('git describe --tags')
|
try:
|
||||||
if status == 0:
|
version = subprocess.check_output(["git", "describe","--tags"]).strip('\n')
|
||||||
version = output
|
except :
|
||||||
else:
|
version = "UNKNOWN"
|
||||||
version = 'unkonwn'
|
|
||||||
#######
|
#######
|
||||||
|
|
||||||
ui_secret = ''.join(random.choice(string.ascii_letters+string.digits) for i in range(16))
|
ui_secret = ''.join(random.choice(string.ascii_letters+string.digits) for i in range(16))
|
||||||
@ -116,6 +122,7 @@ render(os.path.join(templates_dir, "ui", "env"),
|
|||||||
self_registration=self_registration,
|
self_registration=self_registration,
|
||||||
use_compressed_js=use_compressed_js,
|
use_compressed_js=use_compressed_js,
|
||||||
ui_secret=ui_secret,
|
ui_secret=ui_secret,
|
||||||
|
secret_key=secret_key,
|
||||||
verify_remote_cert=verify_remote_cert,
|
verify_remote_cert=verify_remote_cert,
|
||||||
token_expiration=token_expiration,
|
token_expiration=token_expiration,
|
||||||
version=version)
|
version=version)
|
||||||
@ -143,6 +150,7 @@ render(os.path.join(templates_dir, "jobservice", "env"),
|
|||||||
db_password=db_password,
|
db_password=db_password,
|
||||||
ui_secret=ui_secret,
|
ui_secret=ui_secret,
|
||||||
max_job_workers=max_job_workers,
|
max_job_workers=max_job_workers,
|
||||||
|
secret_key=secret_key,
|
||||||
ui_url=ui_url,
|
ui_url=ui_url,
|
||||||
verify_remote_cert=verify_remote_cert)
|
verify_remote_cert=verify_remote_cert)
|
||||||
|
|
||||||
@ -188,7 +196,6 @@ def openssl_is_installed(stat):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if customize_crt == 'on':
|
if customize_crt == 'on':
|
||||||
import subprocess
|
|
||||||
shell_stat = subprocess.check_call(["which", "openssl"], stdout=FNULL, stderr=subprocess.STDOUT)
|
shell_stat = subprocess.check_call(["which", "openssl"], stdout=FNULL, stderr=subprocess.STDOUT)
|
||||||
if openssl_is_installed(shell_stat):
|
if openssl_is_installed(shell_stat):
|
||||||
private_key_pem = os.path.join(config_dir, "ui", "private_key.pem")
|
private_key_pem = os.path.join(config_dir, "ui", "private_key.pem")
|
||||||
|
@ -21,4 +21,3 @@ TOKEN_URL=http://ui
|
|||||||
VERIFY_REMOTE_CERT=$verify_remote_cert
|
VERIFY_REMOTE_CERT=$verify_remote_cert
|
||||||
TOKEN_EXPIRATION=$token_expiration
|
TOKEN_EXPIRATION=$token_expiration
|
||||||
VERSION=$version
|
VERSION=$version
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user