41 lines
994 B
Python
41 lines
994 B
Python
# Copyright: (c) 2025, Luca Bilke <luca@bil.ke>
|
|
# MIT License (see LICENSE)
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING, Any
|
|
|
|
if TYPE_CHECKING:
|
|
from ansible_collections.snailed.ez_docker.plugins.module_utils.models import State
|
|
|
|
DOCUMENTATION = """
|
|
docker_volume_backupper:
|
|
description:
|
|
- Configuration for docker_volume_backupper labels.
|
|
type: list
|
|
elements: dict
|
|
suboptions:
|
|
stop:
|
|
description:
|
|
- If true, stop the container when backing up.
|
|
type: bool
|
|
required: true
|
|
"""
|
|
|
|
EXTRA_ARGS = {
|
|
"stop": {"type": "bool", "required": True},
|
|
}
|
|
|
|
|
|
def helper(state: State, _service_name: str, params: dict[str, Any]) -> dict[str, Any]:
|
|
stop: bool = params["stop"]
|
|
project_name: str = state.params["name"]
|
|
|
|
update: dict[str, Any] = {}
|
|
|
|
if stop:
|
|
update["labels"] = {
|
|
"docker-volume-backup.stop-during-backup": project_name,
|
|
}
|
|
|
|
return update
|