39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
# Copyright: (c) 2025, Luca Bilke <luca@bil.ke>
|
|
# MIT License (see LICENSE)
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING, Any, Callable
|
|
|
|
from ansible_collections.snailed.ez_docker.plugins.module_utils.common import recursive_update
|
|
|
|
if TYPE_CHECKING:
|
|
from ansible_collections.snailed.ez_docker.plugins.module_utils.models import State
|
|
|
|
|
|
BASE_ARGS: dict[str, Any] = {}
|
|
|
|
|
|
def apply_update(
|
|
service: dict[str, Any],
|
|
update: dict[str, Any],
|
|
) -> dict[str, Any]:
|
|
return recursive_update(service, update)
|
|
|
|
|
|
def get_default_args(state: State, helper_name: str) -> dict[str, Any]:
|
|
settings: dict[str, Any] = state.params.get("settings", {})
|
|
label_default_args: dict[str, Any] = settings.get("label_default_args", {})
|
|
default_args: dict[str, Any] = label_default_args.get(helper_name, {})
|
|
return default_args
|
|
|
|
|
|
def run_helper(
|
|
state: State,
|
|
service_name: str,
|
|
service: dict[str, Any],
|
|
params: dict[str, Any],
|
|
helper: Callable[[State, str, dict[str, Any]], dict[str, Any]] = lambda _a, _b, _c: {},
|
|
) -> dict[str, Any]:
|
|
update = helper(state, service_name, params)
|
|
return apply_update(service, update)
|