29 lines
992 B
Python
29 lines
992 B
Python
# Copyright: (c) 2025, Luca Bilke <luca@bil.ke>
|
|
# MIT License (see LICENSE)
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING, Any
|
|
|
|
from ansible_collections.snailed.ez_docker.plugins.module_utils import label, spec
|
|
|
|
if TYPE_CHECKING:
|
|
from ansible_collections.snailed.ez_docker.plugins.module_utils.models import State
|
|
|
|
FORCE_ARGS = {
|
|
"name": {"type": "str", "required": True},
|
|
"definition": {"type": "dict", "required": True},
|
|
"label_helpers": spec.label_argument_spec(),
|
|
}
|
|
|
|
|
|
def helper(state: State, service_params: dict[str, Any]) -> dict[str, Any]:
|
|
update: dict[str, Any] = {}
|
|
|
|
for name, labels_params in service_params.get("label_helpers", {}).items():
|
|
for label_params in labels_params:
|
|
params = label.common.get_default_args(state, name) | label_params
|
|
helper = getattr(label, name).helper
|
|
update |= label.common.run_helper(state, service_params["name"], update, params, helper)
|
|
|
|
return update
|