Overwrite some attributes in harbor.cfg 1.5

The values of "redis_url" and "max_job_workers" should be set to new
values due to new implementation.
This commit is contained in:
wangyan 2018-04-30 09:57:01 -07:00 committed by Tan Jiang
parent 2229217a2b
commit 2b3d70357e

View File

@ -3,6 +3,13 @@ import utils
import os
acceptable_versions = ['1.2.0', '1.3.0', '1.4.0']
#The dict overwrite is for overwriting any value that was set in previous cfg,
#which needs a new value in new version of .cfg
overwrite = {
'redis_url':'redis:6379',
'max_job_workers':'50'
}
#The dict default is for filling in the values that are not set in previous config files.
#In 1.5 template the placeholder has the same value as the attribute name.
default = {
'log_rotate_count':'50',
@ -10,7 +17,6 @@ default = {
'db_host':'mysql',
'db_port':'3306',
'db_user':'root',
'redis_url':'',
'clair_db_host':'postgres',
'clair_db_port':'5432',
'clair_db_username':'postgres',
@ -27,11 +33,14 @@ default = {
def migrate(input_cfg, output_cfg):
d = utils.read_conf(input_cfg)
keys = list(default.keys())
keys.extend(overwrite.keys())
keys.extend(['hostname', 'ui_url_protocol', 'max_job_workers', 'customize_crt',
'ssl_cert', 'ssl_cert_key', 'secretkey_path', 'admiral_url', 'db_password', 'clair_db_password'])
val = {}
for k in keys:
if k in d:
if k in overwrite:
val[k] = overwrite[k]
elif k in d:
val[k] = d[k]
else:
val[k] = default[k]