update ansible collections sops, docker and debops
This commit is contained in:
parent
f1135b818f
commit
e31ee5e39c
910 changed files with 27667 additions and 19786 deletions
|
|
@ -20,7 +20,7 @@ from ansible_collections.community.docker.plugins.inventory.docker_containers im
|
|||
)
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
from collections.abc import Callable
|
||||
from collections.abc import Callable # pragma: no cover
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", name="templar")
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ from ansible_collections.community.docker.tests.unit.plugins.module_utils._api.c
|
|||
from .. import fake_api
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
from ansible_collections.community.docker.plugins.module_utils._api.auth import (
|
||||
from ansible_collections.community.docker.plugins.module_utils._api.auth import ( # pragma: no cover
|
||||
AuthConfig,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ from ansible_collections.community.docker.tests.unit.plugins.module_utils._api.c
|
|||
from . import fake_stat
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
from collections.abc import Callable
|
||||
from collections.abc import Callable # pragma: no cover
|
||||
|
||||
|
||||
CURRENT_VERSION = f"v{DEFAULT_DOCKER_API_VERSION}"
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ from ansible_collections.community.docker.plugins.module_utils._copy import (
|
|||
)
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
from collections.abc import Sequence
|
||||
from collections.abc import Sequence # pragma: no cover
|
||||
|
||||
T = t.TypeVar("T")
|
||||
T = t.TypeVar("T") # pragma: no cover
|
||||
|
||||
|
||||
def _simple_generator(sequence: Sequence[T]) -> t.Generator[T]:
|
||||
|
|
|
|||
|
|
@ -61,12 +61,10 @@ def test_archived_image_manifest_extracts_nothing_when_file_not_present(
|
|||
|
||||
|
||||
def test_archived_image_manifest_raises_when_file_not_a_tar() -> None:
|
||||
try:
|
||||
with pytest.raises(ImageArchiveInvalidException, match=__file__) as exc_info:
|
||||
archived_image_manifest(__file__)
|
||||
raise AssertionError()
|
||||
except ImageArchiveInvalidException as e:
|
||||
assert isinstance(e.__cause__, tarfile.ReadError)
|
||||
assert str(__file__) in str(e)
|
||||
assert isinstance(exc_info.value.__cause__, tarfile.ReadError)
|
||||
assert str(__file__) in str(exc_info.value)
|
||||
|
||||
|
||||
def test_archived_image_manifest_raises_when_tar_missing_manifest(
|
||||
|
|
@ -74,12 +72,10 @@ def test_archived_image_manifest_raises_when_tar_missing_manifest(
|
|||
) -> None:
|
||||
write_irrelevant_tar(tar_file_name)
|
||||
|
||||
try:
|
||||
with pytest.raises(ImageArchiveInvalidException) as exc_info:
|
||||
archived_image_manifest(tar_file_name)
|
||||
raise AssertionError()
|
||||
except ImageArchiveInvalidException as e:
|
||||
assert isinstance(e.__cause__, KeyError)
|
||||
assert "manifest.json" in str(e.__cause__)
|
||||
assert isinstance(exc_info.value.__cause__, KeyError)
|
||||
assert "manifest.json" in str(exc_info.value.__cause__)
|
||||
|
||||
|
||||
def test_archived_image_manifest_raises_when_manifest_missing_id(
|
||||
|
|
@ -89,9 +85,7 @@ def test_archived_image_manifest_raises_when_manifest_missing_id(
|
|||
|
||||
write_imitation_archive_with_manifest(tar_file_name, manifest)
|
||||
|
||||
try:
|
||||
with pytest.raises(ImageArchiveInvalidException) as exc_info:
|
||||
archived_image_manifest(tar_file_name)
|
||||
raise AssertionError()
|
||||
except ImageArchiveInvalidException as e:
|
||||
assert isinstance(e.__cause__, KeyError)
|
||||
assert "Config" in str(e.__cause__)
|
||||
assert isinstance(exc_info.value.__cause__, KeyError)
|
||||
assert "Config" in str(exc_info.value.__cause__)
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ from ansible_collections.community.docker.plugins.module_utils._util import (
|
|||
|
||||
if t.TYPE_CHECKING:
|
||||
|
||||
class DAMSpec(t.TypedDict):
|
||||
class DAMSpec(t.TypedDict): # pragma: no cover
|
||||
av: dict[str, t.Any]
|
||||
bv: dict[str, t.Any]
|
||||
result: bool
|
||||
|
||||
class Spec(t.TypedDict):
|
||||
class Spec(t.TypedDict): # pragma: no cover
|
||||
a: t.Any
|
||||
b: t.Any
|
||||
method: t.Literal["strict", "ignore", "allow_more_present"]
|
||||
|
|
|
|||
|
|
@ -21,11 +21,13 @@ from ..test_support.docker_image_archive_stubbing import (
|
|||
)
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
from collections.abc import Callable
|
||||
from collections.abc import Callable # pragma: no cover
|
||||
|
||||
|
||||
def assert_no_logging(msg: str) -> t.NoReturn:
|
||||
raise AssertionError(f"Should not have logged anything but logged {msg}")
|
||||
raise AssertionError(
|
||||
f"Should not have logged anything but logged {msg}"
|
||||
) # pragma: no cover
|
||||
|
||||
|
||||
def capture_logging(messages: list[str]) -> Callable[[str], None]:
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ from ansible_collections.community.docker.plugins.modules import (
|
|||
docker_swarm_service,
|
||||
)
|
||||
|
||||
APIError = pytest.importorskip("docker.errors.APIError")
|
||||
docker_errors = pytest.importorskip("docker.errors")
|
||||
APIError = docker_errors.APIError
|
||||
|
||||
|
||||
def test_retry_on_out_of_sequence_error(mocker: t.Any) -> None:
|
||||
|
|
@ -375,3 +376,79 @@ def test_get_docker_networks() -> None:
|
|||
docker_swarm_service.get_docker_networks(
|
||||
[{"name": "test", "nonexisting_option": "foo"}], {"test": "1"}
|
||||
)
|
||||
|
||||
|
||||
def test_combine_command_args() -> None:
|
||||
"""command + args combine into a single argv list for CLI-compatible mode."""
|
||||
combine = docker_swarm_service._combine_command_args
|
||||
assert combine(None, None) is None
|
||||
assert combine(["sleep"], ["3600"]) == ["sleep", "3600"]
|
||||
# Flag-style command alone (issue #1044 / #212)
|
||||
assert combine(["-config.file=/etc/loki/loki-config.yaml"], None) == [
|
||||
"-config.file=/etc/loki/loki-config.yaml"
|
||||
]
|
||||
assert combine(None, ["--path.rootfs=/host"]) == ["--path.rootfs=/host"]
|
||||
assert combine(["prometheus"], ["--config.file=a.yml"]) == [
|
||||
"prometheus",
|
||||
"--config.file=a.yml",
|
||||
]
|
||||
|
||||
|
||||
def _make_service(
|
||||
command: list[str] | None = None,
|
||||
args: list[str] | None = None,
|
||||
command_as_args: bool = False,
|
||||
) -> docker_swarm_service.DockerService:
|
||||
svc = docker_swarm_service.DockerService(
|
||||
docker_swarm_service.LooseVersion("1.40"),
|
||||
docker_swarm_service.LooseVersion("5.0.0"),
|
||||
)
|
||||
svc.image = "alpine:latest"
|
||||
svc.command = command
|
||||
svc.args = args
|
||||
svc.command_as_args = command_as_args
|
||||
return svc
|
||||
|
||||
|
||||
def test_build_container_spec_legacy_command_mapping(mocker: t.Any) -> None:
|
||||
"""Default command_as_args=false keeps historical Command/Args split."""
|
||||
captured: dict[str, t.Any] = {}
|
||||
|
||||
class FakeContainerSpec:
|
||||
def __init__(self, image: str, **kwargs: t.Any) -> None:
|
||||
captured["image"] = image
|
||||
captured.update(kwargs)
|
||||
|
||||
mocker.patch.object(docker_swarm_service.types, "ContainerSpec", FakeContainerSpec)
|
||||
|
||||
svc = _make_service(command=["sleep"], args=["3600"], command_as_args=False)
|
||||
svc.build_container_spec()
|
||||
assert captured.get("command") == ["sleep"]
|
||||
assert captured.get("args") == ["3600"]
|
||||
|
||||
|
||||
def test_build_container_spec_command_as_args(mocker: t.Any) -> None:
|
||||
"""command_as_args=true maps command+args to ContainerSpec.Args only."""
|
||||
captured: dict[str, t.Any] = {}
|
||||
|
||||
class FakeContainerSpec:
|
||||
def __init__(self, image: str, **kwargs: t.Any) -> None:
|
||||
captured["image"] = image
|
||||
captured.update(kwargs)
|
||||
|
||||
mocker.patch.object(docker_swarm_service.types, "ContainerSpec", FakeContainerSpec)
|
||||
|
||||
svc = _make_service(
|
||||
command=["-config.file=/etc/loki/loki-config.yaml"],
|
||||
args=None,
|
||||
command_as_args=True,
|
||||
)
|
||||
svc.build_container_spec()
|
||||
assert "command" not in captured
|
||||
assert captured.get("args") == ["-config.file=/etc/loki/loki-config.yaml"]
|
||||
|
||||
captured.clear()
|
||||
svc = _make_service(command=["sleep"], args=["3600"], command_as_args=True)
|
||||
svc.build_container_spec()
|
||||
assert "command" not in captured
|
||||
assert captured.get("args") == ["sleep", "3600"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue