Adapted discourse version to new code after the big refactoring

This commit is contained in:
2025-07-20 09:29:56 +02:00
parent 1b9775ccb5
commit d86ca6cc0e
11 changed files with 81 additions and 21 deletions

View File

@@ -13,6 +13,12 @@ class FilterModule(object):
seen_domains = {}
for app_id, cfg in apps.items():
if not isinstance(cfg, dict):
raise AnsibleFilterError(
f"Invalid configuration for application '{app_id}': "
f"expected a dict, got {cfg!r}"
)
domains_cfg = cfg.get('domains')
if not domains_cfg or 'canonical' not in domains_cfg:
self._add_default_domain(app_id, primary_domain, seen_domains, result)

View File

@@ -2,6 +2,7 @@ import os
import re
import yaml
from ansible.errors import AnsibleFilterError
from collections.abc import Mapping
from ansible.errors import AnsibleUndefinedVariable
try:
@@ -62,12 +63,15 @@ def get_app_conf(applications, application_id, config_path, strict=True, default
return default if default is not None else False
raise AppConfigKeyError(
f"Key '{k}' is undefined at '{'.'.join(path_trace)}'\n"
f" actual type: {type(obj).__name__}\n"
f" repr(obj): {obj!r}\n"
f" repr(applications): {applications!r}\n"
f"application_id: {application_id}\n"
f"config_path: {config_path}"
)
# Access dict key
if isinstance(obj, dict):
if isinstance(obj, Mapping):
if k not in obj:
# Non-strict mode: always return default on missing key
if not strict: