Files
computer-playbook/module_utils/docker_paths_utils.py
T
kevinveenbirkenbach 24616b2d35 refactor: extract get_docker_paths to module_utils and fix affected tests
- Move get_docker_paths() implementation from filter_plugins to module_utils
  to make it reusable by filters and lookup plugins (single source of truth)
- Adapt filter_plugins/get_docker_paths.py to re-export the shared util
- Add new lookup plugin "database" resolving DB settings from applications config
- Fix unit test patching: patch module_utils.docker_paths_utils.get_entity_name
  instead of filter module, because imports are now bound at util level
- Add comprehensive unit tests for database lookup covering all helper-variable cases

https://chatgpt.com/share/6983b526-00dc-800f-b3a0-b71e4104d0fc
2026-02-04 22:07:42 +01:00

31 lines
1.1 KiB
Python

# module_utils/docker_paths_utils.py
from __future__ import annotations
from module_utils.entity_name_utils import get_entity_name
def get_docker_paths(application_id: str, path_docker_compose_instances: str) -> dict:
"""
Build the docker_compose dict based on path_docker_compose_instances and application_id.
Uses get_entity_name to extract the entity name from application_id.
"""
entity = get_entity_name(application_id)
base = f"{path_docker_compose_instances}{entity}/"
return {
"directories": {
"instance": base,
"env": f"{base}.env/",
"services": f"{base}services/",
"volumes": f"{base}volumes/",
"config": f"{base}config/",
},
"files": {
"env": f"{base}.env/env",
"docker_compose": f"{base}docker-compose.yml",
"docker_compose_override": f"{base}docker-compose.override.yml",
"docker_compose_ca_override": f"{base}docker-compose.ca.override.yml",
"dockerfile": f"{base}Dockerfile",
},
}