Generates config file tenantConfig.json
for each tenant.
GlobalConfigGenerator is based on jsonmerge
package.
Create a GlobalConfigGenerator config file globalConfig.json
(see below).
Example globalConfig.json
:
{
"$schema": "https://github.com/naub1n/qwc-global-config-generator/raw/master/schemas/qwc-global-config-generator.json",
"service": "global-config-generator",
"config": {
"config_generator_service_url": "http://qwc-config-service:9090"
},
"common_config": {
"config-generator-service": {
"$schema": "https://github.com/qwc-services/qwc-config-generator/raw/master/schemas/qwc-config-generator.json",
"service": "config-generator",
"config": {
"default_qgis_server_url": "http://qwc-qgis-server/ows/",
"config_db_url": "postgresql:///?service=qwc_configdb",
"permissions_default_allow": true,
"qgis_projects_base_dir": "/data/default",
"qgis_projects_scan_base_dir": "/data/default/scan",
"qgis_projects_gen_base_dir": "/data/default/gen",
"qwc2_base_dir": "/qwc2"
},
"themesConfig": {},
"services": []
},
"qwc2config": {
"searchServiceUrl": "http://localhost:5011/",
"searchDataServiceUrl": "http://localhost:5011/geom/",
"editServiceUrl": "http://localhost:5012/"
}
},
"specific_configs": [
{
"tenant": "default"
},
{
"tenant": "test",
"config-generator-service": {
"themesConfig": {
"defaultMapCrs": "EPSG:2154"
}
},
"qwc2config": {
"searchServiceUrl": "http://localhost:50020/"
}
}
]
}
- GlobalConfigGenerator read each
tenant
name inspecific_configs
key. - GlobalConfigGenerator take data of
config-generator-service
sub-key incommon_config
key. - For each tenant GlobalConfigGenerator read data of
config-generator-service
sub-key inspecific_configs
key. - GlobalConfigGenerator apply merge strategy for each similar keys between
common_config
key andspecific_configs
key - GlobalConfigGenerator export
tenantConfig.json
file in tenant directory.
- GlobalConfigGenerator read each
tenant
name inspecific_configs
key. - GlobalConfigGenerator take data of
qwc2config
sub-key incommon_config
key. - For each tenant GlobalConfigGenerator read data of
qwc2config
sub-key inspecific_configs
key. - GlobalConfigGenerator apply merge strategy for each similar keys between
common_config
key andspecific_configs
key - GlobalConfigGenerator export
config.json
file in tenant directory.
- GlobalConfigGenerator read each
tenant
name inspecific_configs
key. - GlobalConfigGenerator read and copy
index.html
in each tenant directory
GlobalConfigGenerator use JSON schema specification to specify the merge strategy.
Merge schema used is merge_schema_for_config_generator.json
Default strategy:
- All items in
services
key are merged byname
key. - All items in
items
key are appended. - All items in
defaultBackgroundLayers
key are appended. - All items in
defaultSearchProviders
key are appended.
Merge schema used is merge_schema_for_qwc2_config.json
Default strategy:
- No strategy used
GlobalConfigGenerator use a template value to add tenant fo each value in globalConfig.json file.
Add %tenant%
value in common configuration.
%tenant%
will be replaced by tenant name for each item in specific configuration.
Then, GlobalConfigGenerator apply schema rules.
- Create a
globalConfig.json
file in root ofconfig-in
directory.-
Add data to
common_config
key.-
Add data to
config-generator-service
key.
Read qwc-config-generator-service description to see all data which can be added. -
Add data to
qwc2config
key
Read QWC2 application configuration description and config.json file to see all data which can be added.
-
-
Add data to
specific_configs
keyOne tenant name is minimal requirement. you can add this data :
{ "tenant": "default" }
Add all subkeys you want to add or modify in
config-generator-service
key orqwc2config
key.You should respect json tree!! Add all parents keys before the specific key you want to modify.
Exemple : If you want to modify
defaultMapCrs
key in a tenant, you should addthemesConfig
parent key like:{ "tenant": "TheTenantNameIWantToModify", "config-generator-service": { "themesConfig": { "defaultMapCrs": "EPSG:2154" } } }
-
- Create an
index.html
file in root ofconfig-in
directory.
Use default index.html file or create yours.
Set the INPUT_CONFIG_PATH
environment variable to the base directory where for the configuration files are that should be read by the ConfigGenerator (default: config-in/
).
NOTE: the ConfigGenerator's docker user (www-data
) needs to have write permissions to the directory defined in INPUT_CONFIG_PATH
!
Base URL:
http://localhost:5010/
Generate configs for all tenant:
curl -X POST "http://localhost:5010/generate_configs?"
Create a virtual environment:
virtualenv --python=/usr/bin/python3 --system-site-package .venv
Activate virtual environment:
source .venv/bin/activate
Install requirements:
pip install -r requirements.txt
Set the INPUT_CONFIG_PATH environment variable (default: config-in).
export INPUT_CONFIG_PATH=../qwc-docker/volumes/config-in
Configure environment:
echo FLASK_ENV=development >.flaskenv
Start local service:
python server.py