Refactor resource_filter to delegate default handling to get_app_conf and update unittests accordingly https://chatgpt.com/share/68d3ad6d-76b4-800f-b04e-5e1fb70b44f3

This commit is contained in:
2025-09-24 10:46:21 +02:00
parent 9ba0efc1a1
commit 929cddec0e
2 changed files with 50 additions and 16 deletions

View File

@@ -28,12 +28,7 @@ def resource_filter(
"""
try:
primary_service = service_name if service_name != "" else get_entity_name(application_id)
val = get_app_conf(applications, f"docker.services.{primary_service}.{key}", False, None)
if val is not None:
return val
return hard_default
return get_app_conf(applications, application_id, f"docker.services.{primary_service}.{key}", False, hard_default)
except (AppConfigKeyError, ConfigEntryNotSetError) as e:
raise AnsibleFilterError(str(e))