Skip to content

Commit

Permalink
Generate config-only services configurations (#65)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Sandro Mani <[email protected]>
  • Loading branch information
benoitblanc and manisandro authored Feb 6, 2024
1 parent c85c8ea commit 041b693
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 29 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": "<service_name>",
"schema_url": "<service_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
-----
Expand Down
41 changes: 12 additions & 29 deletions src/config_generator/config_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import requests
import tempfile
import re

from collections import OrderedDict
from datetime import datetime
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 041b693

Please sign in to comment.