Skip to content

Commit bb66358

Browse files
ninjadqwy65701436
authored andcommitted
Update migratrion script (goharbor#7728)
* Fix migration script 1. port is string when parsed from configparser 2. remove index and db_user in if condition Signed-off-by: Qian Deng <dengq@vmware.com> * Add port to public_url Add port to public_url Signed-off-by: Qian Deng <dengq@vmware.com> * Customized value for notary and clair db config in notary and clair is hardcoded Signed-off-by: Qian Deng <dengq@vmware.com> * Add notary and clair db config in harbor.yml Add notary clair config to harbor.yml and fix related regression Signed-off-by: Qian Deng <dengq@vmware.com>
1 parent 4218206 commit bb66358

File tree

14 files changed

+137
-67
lines changed

14 files changed

+137
-67
lines changed

make/harbor.yml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,34 @@ _version: 1.8.0
8383
# Uncomment external_database if using external database. And the password will replace the the password setting in database.
8484
# And currently only support postgres.
8585
# external_database:
86-
# host: postgresql
87-
# port: 5432
88-
# username: postgres
89-
# password: root123
90-
# ssl_mode: disable
86+
# harbor:
87+
# host: postgresql
88+
# port: 5432
89+
# db_name: registry
90+
# username: postgres
91+
# password: root123
92+
# ssl_mode: disable
93+
# clair:
94+
# host: postgresql
95+
# port: 5432
96+
# db_name: registry
97+
# username: postgres
98+
# password: root123
99+
# ssl_mode: disable
100+
# notary_signer:
101+
# host: postgresql
102+
# port: 5432
103+
# db_name: registry
104+
# username: postgres
105+
# password: root123
106+
# ssl_mode: disable
107+
# notary_server:
108+
# host: postgresql
109+
# port: 5432
110+
# db_name: registry
111+
# username: postgres
112+
# password: root123
113+
# ssl_mode: disable
91114

92115
# Uncomment external_redis if using external Redis server
93116
# external_redis:
@@ -101,4 +124,4 @@ _version: 1.8.0
101124

102125
# Uncomment uaa for trusting the certificate of uaa instance that is hosted via self-signed cert.
103126
# uaa:
104-
# ca_file: /path/to/ca
127+
# ca_file: /path/to/ca

make/photon/prepare/templates/clair/config.yaml.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ clair:
22
database:
33
type: pgsql
44
options:
5-
source: postgresql://{{username}}:{{password}}@{{host}}:{{port}}/{{dbname}}?sslmode=disable
5+
source: postgresql://{{clair_db_username}}:{{clair_db_password}}@{{clair_db_host}}:{{clair_db_port}}/{{clair_db_name}}?sslmode={{clair_db_sslmode}}
66

77
# Number of elements kept in the cache
88
# Values unlikely to change (e.g. namespaces) are cached in order to save prevent needless roundtrips to the database.
@@ -16,7 +16,7 @@ clair:
1616
# Deadline before an API request will respond with a 503
1717
timeout: 300s
1818
updater:
19-
interval: {{interval}}h
19+
interval: {{clair_updaters_interval}}h
2020

2121
notifier:
2222
attempts: 3
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
POSTGRES_PASSWORD={{password}}
1+
POSTGRES_PASSWORD={{clair_db_password}}

make/photon/prepare/templates/core/env.jinja

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ PORT=8080
99
LOG_LEVEL={{log_level}}
1010
EXT_ENDPOINT={{public_url}}
1111
DATABASE_TYPE=postgresql
12-
POSTGRESQL_HOST={{db_host}}
13-
POSTGRESQL_PORT={{db_port}}
14-
POSTGRESQL_USERNAME={{db_user}}
15-
POSTGRESQL_PASSWORD={{db_password}}
16-
POSTGRESQL_DATABASE=registry
17-
POSTGRESQL_SSLMODE=disable
12+
POSTGRESQL_HOST={{harbor_db_host}}
13+
POSTGRESQL_PORT={{harbor_db_port}}
14+
POSTGRESQL_USERNAME={{harbor_db_username}}
15+
POSTGRESQL_PASSWORD={{harbor_db_password}}
16+
POSTGRESQL_DATABASE={{harbor_db_name}}
17+
POSTGRESQL_SSLMODE={{harbor_db_sslmode}}
1818
REGISTRY_URL={{registry_url}}
1919
TOKEN_SERVICE_URL={{token_service_url}}
2020
HARBOR_ADMIN_PASSWORD={{harbor_admin_password}}
@@ -24,12 +24,12 @@ JOBSERVICE_SECRET={{jobservice_secret}}
2424
ADMIRAL_URL={{admiral_url}}
2525
WITH_NOTARY={{with_notary}}
2626
WITH_CLAIR={{with_clair}}
27-
CLAIR_DB_PASSWORD={{db_password}}
28-
CLAIR_DB_HOST={{db_host}}
29-
CLAIR_DB_PORT={{db_port}}
30-
CLAIR_DB_USERNAME={{db_user}}
31-
CLAIR_DB={{clair_db}}
32-
CLAIR_DB_SSLMODE=disable
27+
CLAIR_DB_PASSWORD={{clair_db_password}}
28+
CLAIR_DB_HOST={{clair_db_host}}
29+
CLAIR_DB_PORT={{clair_db_port}}
30+
CLAIR_DB_USERNAME={{clair_db_username}}
31+
CLAIR_DB={{clair_db_name}}
32+
CLAIR_DB_SSLMODE={{clair_db_sslmode}}
3333
CORE_URL={{core_url}}
3434
JOBSERVICE_URL={{jobservice_url}}
3535
CLAIR_URL={{clair_url}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
POSTGRES_PASSWORD={{db_password}}
1+
POSTGRES_PASSWORD={{harbor_db_password}}

make/photon/prepare/templates/notary/server-config.postgres.json.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"storage": {
1616
"backend": "postgres",
17-
"db_url": "postgres://server:password@postgresql:5432/notaryserver?sslmode=disable"
17+
"db_url": "postgres://{{notary_server_db_username}}:{{notary_server_db_password}}@{{notary_server_db_host}}:{{notary_server_db_port}}/{{notary_server_db_name}}?sslmode={{notary_server_db_sslmode}}"
1818
},
1919
"auth": {
2020
"type": "token",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
MIGRATIONS_PATH=migrations/server/postgresql
2-
DB_URL=postgres://server:password@postgresql:5432/notaryserver?sslmode=disable
2+
DB_URL=postgres://{{notary_server_db_username}}:{{notary_server_db_password}}@{{notary_server_db_host}}:{{notary_server_db_port}}/{{notary_server_db_name}}?sslmode={{notary_server_db_sslmode}}

make/photon/prepare/templates/notary/signer-config.postgres.json.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"storage": {
1111
"backend": "postgres",
12-
"db_url": "postgres://signer:password@postgresql:5432/notarysigner?sslmode=disable",
13-
"default_alias":"defaultalias"
12+
"db_url": "postgres://{{notary_signer_db_username}}:{{notary_signer_db_password}}@{{notary_signer_db_host}}:{{notary_signer_db_port}}/{{notary_signer_db_name}}?sslmode={{notary_signer_db_sslmode}}",
13+
"default_alias": "{{alias}}"
1414
}
1515
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
NOTARY_SIGNER_DEFAULTALIAS={{alias}}
22
MIGRATIONS_PATH=migrations/signer/postgresql
3-
DB_URL=postgres://signer:password@postgresql:5432/notarysigner?sslmode=disable
3+
DB_URL=postgres://{{notary_signer_db_username}}:{{notary_signer_db_password}}@{{notary_signer_db_host}}:{{notary_signer_db_port}}/{{notary_signer_db_name}}?sslmode={{notary_signer_db_sslmode}}

make/photon/prepare/utils/clair.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,14 @@ def prepare_clair(config_dict):
2727
render_jinja(
2828
postgres_env_template,
2929
postgres_env_path,
30-
password=config_dict['db_password'])
30+
**config_dict)
3131

3232
render_jinja(
3333
clair_config_template,
3434
clair_config_path,
3535
uid=DEFAULT_UID,
3636
gid=DEFAULT_GID,
37-
password= config_dict['db_password'],
38-
username= config_dict['db_user'],
39-
host= config_dict['db_host'],
40-
port= config_dict['db_port'],
41-
dbname= config_dict['clair_db'],
42-
interval= config_dict['clair_updaters_interval'])
37+
**config_dict)
4338

4439
# config http proxy for Clair
4540
render_jinja(

0 commit comments

Comments
 (0)