37 lines
981 B
Python
37 lines
981 B
Python
# Copyright: (c) 2024, Luca Bilke <luca@bil.ke>
|
|
# MIT License (see LICENSE)
|
|
|
|
from __future__ import annotations
|
|
|
|
import copy
|
|
from typing import TYPE_CHECKING, Any
|
|
|
|
from ansible_collections.ssnailed.ez_compose.plugins.module_utils.service import ( # type: ignore[reportMissingTypeStubs]
|
|
common as service,
|
|
)
|
|
|
|
if TYPE_CHECKING:
|
|
from ansible_collections.ssnailed.ez_compose.plugins.module_utils.common import ( # type: ignore[reportMissingTypeStubs]
|
|
State,
|
|
)
|
|
|
|
EXTRA_ARGS = {
|
|
"internal_network": {"type": "bool", "default": False},
|
|
"definition": {"type": "dict", "required": True},
|
|
}
|
|
|
|
|
|
def helper(state: State, params: dict[str, Any]) -> State:
|
|
definition = params["definition"]
|
|
internal_network = params["internal_network"]
|
|
|
|
update = copy.deepcopy(definition)
|
|
|
|
networks = update.get("networks", {})
|
|
|
|
if internal_network:
|
|
networks["internal"] = None
|
|
|
|
update["networks"] = networks
|
|
|
|
return service.update(state, update)
|