diff --git a/README.md b/README.md index 2716ebe..b326ce9 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,21 @@ If you want to define custom resource types for a custom service, you can add a and then add it to the `custom_resource_types` setting. +### Additional services + +For any additional service (without specific resources), ConfigGenerator generates the configuration in `OUTPUT_CONFIG_PATH` directory. + +Add the following configuration and adapt it to your service in `tenantConfig.json`: + +```json +{ + "name": "", + "schema_url": "", + "config": {...} +} +``` + +*Note*: `service_name` is expected to be camel case (i.e. `adminGui`), and the service name in the generated config will lowercase and hyphenated (i.e. `admin-gui`). Usage ----- diff --git a/src/config_generator/config_generator.py b/src/config_generator/config_generator.py index 9ae4f48..2756aaf 100644 --- a/src/config_generator/config_generator.py +++ b/src/config_generator/config_generator.py @@ -4,6 +4,7 @@ import os import requests import tempfile +import re from collections import OrderedDict from datetime import datetime @@ -301,37 +302,19 @@ def __init__(self, config, logger, config_file_dir): self.config_models, self.schema_urls.get('ext'), self.service_config('ext'), self.logger ), + } + for service_name, service_config in self.service_configs.items(): # config-only services - 'adminGui': ServiceConfig( - 'adminGui', self.schema_urls.get('adminGui'), - self.service_config('adminGui'), self.logger, 'admin-gui' - ), - 'dbAuth': ServiceConfig( - 'dbAuth', self.schema_urls.get('dbAuth'), - self.service_config('dbAuth'), self.logger, 'db-auth' - ), - 'ldapAuth': ServiceConfig( - 'ldapAuth', self.schema_urls.get('ldapAuth'), - self.service_config('ldapAuth'), self.logger, 'ldap-auth' - ), - 'oidcAuth': ServiceConfig( - 'oidcAuth', self.schema_urls.get('oidcAuth'), - self.service_config('oidcAuth'), self.logger, 'oidc-auth' - ), - 'elevation': ServiceConfig( - 'elevation', self.schema_urls.get('elevation'), - self.service_config('elevation'), self.logger - ), - 'mapinfo': ServiceConfig( - 'mapinfo', self.schema_urls.get('mapinfo'), - self.service_config('mapinfo'), self.logger - ), - 'permalink': ServiceConfig( - 'permalink', self.schema_urls.get('permalink'), - self.service_config('permalink'), self.logger - ) - } + if service_name not in self.config_handler: + # if service is not yet in config handler, it has not a specific service configuration, it is a config-only service + schema_url = self.schema_urls.get(service_name, service_config.get('schema_url', '')) + config = ServiceConfig(service_name, schema_url, + self.service_config(service_name), self.logger, + re.sub(r'(?=[A-Z])', '-', service_name).lower()) + self.config_handler[service_name] = config + self.logger.debug(f"Add configuration for service {service_name}") + else: self.logger.debug(f"Specific configuration for service {service_name} already exists") try: # check tenant dirs