# Copyright: (c) 2024, Luca Bilke <luca@bil.ke>
# MIT License (see LICENSE)

from __future__ import annotations

from typing import TYPE_CHECKING, Any

from ansible_collections.ssnailed.ez_compose.plugins.module_utils.service import (
    common as service,
)

if TYPE_CHECKING:
    from ansible_collections.ssnailed.ez_compose.plugins.module_utils.common import (
        State,
    )

EXTRA_ARGS = {
    "read_only": {"type": "bool", "default": True},
}


def helper(state: State, params: dict[str, Any]) -> State:
    read_only = params["read_only"]

    volumes = [
        {
            "type": "bind",
            "source": "/var/run/docker.sock",
            "target": "/var/run/docker.sock",
            "read_only": read_only,
        },
    ]

    update = {
        "volumes": volumes,
    }

    return service.update(params["name"], state, update)