localstack-core 4.9.3.dev25__py3-none-any.whl → 4.9.3.dev27__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of localstack-core might be problematic. Click here for more details.
- localstack/aws/handlers/metric_handler.py +41 -1
- localstack/cli/exceptions.py +1 -1
- localstack/cli/localstack.py +4 -4
- localstack/cli/lpm.py +3 -4
- localstack/cli/profiles.py +1 -2
- localstack/config.py +18 -12
- localstack/constants.py +4 -0
- localstack/packages/api.py +9 -8
- localstack/packages/core.py +2 -2
- localstack/testing/pytest/cloudformation/fixtures.py +3 -3
- localstack/testing/pytest/container.py +4 -5
- localstack/testing/pytest/fixtures.py +20 -19
- localstack/testing/pytest/marking.py +5 -4
- localstack/testing/pytest/stepfunctions/utils.py +4 -3
- localstack/testing/pytest/util.py +1 -1
- localstack/testing/pytest/validation_tracking.py +1 -2
- localstack/utils/analytics/events.py +2 -2
- localstack/utils/analytics/metadata.py +1 -2
- localstack/utils/analytics/metrics/counter.py +6 -8
- localstack/utils/analytics/publisher.py +1 -2
- localstack/utils/analytics/service_request_aggregator.py +2 -2
- localstack/utils/archives.py +11 -11
- localstack/utils/aws/arns.py +7 -7
- localstack/utils/aws/aws_responses.py +7 -7
- localstack/utils/aws/aws_stack.py +2 -3
- localstack/utils/aws/message_forwarding.py +1 -2
- localstack/utils/aws/request_context.py +4 -5
- localstack/utils/batch_policy.py +3 -3
- localstack/utils/bootstrap.py +7 -7
- localstack/utils/cloudwatch/cloudwatch_util.py +5 -5
- localstack/utils/collections.py +7 -8
- localstack/utils/config_listener.py +1 -1
- localstack/utils/container_networking.py +2 -3
- localstack/utils/container_utils/container_client.py +115 -131
- localstack/utils/container_utils/docker_cmd_client.py +42 -42
- localstack/utils/container_utils/docker_sdk_client.py +63 -62
- localstack/utils/diagnose.py +2 -3
- localstack/utils/docker_utils.py +3 -4
- localstack/utils/functions.py +3 -2
- localstack/utils/http.py +4 -5
- localstack/utils/json.py +3 -3
- localstack/utils/kinesis/kinesis_connector.py +2 -1
- localstack/utils/net.py +6 -6
- localstack/utils/no_exit_argument_parser.py +2 -2
- localstack/utils/numbers.py +2 -2
- localstack/utils/objects.py +6 -5
- localstack/utils/patch.py +2 -1
- localstack/utils/run.py +10 -9
- localstack/utils/scheduler.py +11 -11
- localstack/utils/server/tcp_proxy.py +2 -2
- localstack/utils/serving.py +2 -3
- localstack/utils/strings.py +10 -11
- localstack/utils/sync.py +2 -1
- localstack/utils/tagging.py +1 -4
- localstack/utils/testutil.py +5 -4
- localstack/utils/threads.py +2 -2
- localstack/utils/time.py +1 -2
- localstack/utils/urls.py +1 -3
- localstack/version.py +2 -2
- {localstack_core-4.9.3.dev25.dist-info → localstack_core-4.9.3.dev27.dist-info}/METADATA +2 -2
- {localstack_core-4.9.3.dev25.dist-info → localstack_core-4.9.3.dev27.dist-info}/RECORD +69 -69
- localstack_core-4.9.3.dev27.dist-info/plux.json +1 -0
- localstack_core-4.9.3.dev25.dist-info/plux.json +0 -1
- {localstack_core-4.9.3.dev25.data → localstack_core-4.9.3.dev27.data}/scripts/localstack +0 -0
- {localstack_core-4.9.3.dev25.data → localstack_core-4.9.3.dev27.data}/scripts/localstack-supervisor +0 -0
- {localstack_core-4.9.3.dev25.data → localstack_core-4.9.3.dev27.data}/scripts/localstack.bat +0 -0
- {localstack_core-4.9.3.dev25.dist-info → localstack_core-4.9.3.dev27.dist-info}/WHEEL +0 -0
- {localstack_core-4.9.3.dev25.dist-info → localstack_core-4.9.3.dev27.dist-info}/entry_points.txt +0 -0
- {localstack_core-4.9.3.dev25.dist-info → localstack_core-4.9.3.dev27.dist-info}/licenses/LICENSE.txt +0 -0
- {localstack_core-4.9.3.dev25.dist-info → localstack_core-4.9.3.dev27.dist-info}/top_level.txt +0 -0
|
@@ -5,21 +5,17 @@ import logging
|
|
|
5
5
|
import os
|
|
6
6
|
import re
|
|
7
7
|
import shlex
|
|
8
|
-
import sys
|
|
9
8
|
import tarfile
|
|
10
9
|
import tempfile
|
|
11
10
|
from abc import ABCMeta, abstractmethod
|
|
11
|
+
from collections.abc import Callable
|
|
12
12
|
from enum import Enum, unique
|
|
13
13
|
from pathlib import Path
|
|
14
14
|
from typing import (
|
|
15
|
-
Callable,
|
|
16
15
|
Literal,
|
|
17
16
|
NamedTuple,
|
|
18
|
-
Optional,
|
|
19
17
|
Protocol,
|
|
20
18
|
TypedDict,
|
|
21
|
-
Union,
|
|
22
|
-
get_args,
|
|
23
19
|
)
|
|
24
20
|
|
|
25
21
|
import dotenv
|
|
@@ -57,7 +53,7 @@ class DockerContainerStats(TypedDict):
|
|
|
57
53
|
MemUsage: tuple[int, int]
|
|
58
54
|
NetIO: tuple[int, int]
|
|
59
55
|
PIDs: int
|
|
60
|
-
SDKStats:
|
|
56
|
+
SDKStats: dict | None
|
|
61
57
|
|
|
62
58
|
|
|
63
59
|
class ContainerException(Exception):
|
|
@@ -143,7 +139,7 @@ class Ulimit:
|
|
|
143
139
|
|
|
144
140
|
name: str
|
|
145
141
|
soft_limit: int
|
|
146
|
-
hard_limit:
|
|
142
|
+
hard_limit: int | None = None
|
|
147
143
|
|
|
148
144
|
def __repr__(self):
|
|
149
145
|
"""Format: <type>=<soft limit>[:<hard limit>]"""
|
|
@@ -154,19 +150,11 @@ class Ulimit:
|
|
|
154
150
|
|
|
155
151
|
|
|
156
152
|
# defines the type for port mappings (source->target port range)
|
|
157
|
-
PortRange =
|
|
153
|
+
PortRange = list | HashableList
|
|
158
154
|
# defines the protocol for a port range ("tcp" or "udp")
|
|
159
155
|
PortProtocol = str
|
|
160
156
|
|
|
161
157
|
|
|
162
|
-
def isinstance_union(obj, class_or_tuple):
|
|
163
|
-
# that's some dirty hack
|
|
164
|
-
if sys.version_info < (3, 10):
|
|
165
|
-
return isinstance(obj, get_args(PortRange))
|
|
166
|
-
else:
|
|
167
|
-
return isinstance(obj, class_or_tuple)
|
|
168
|
-
|
|
169
|
-
|
|
170
158
|
class PortMappings:
|
|
171
159
|
"""Maps source to target port ranges for Docker port mappings."""
|
|
172
160
|
|
|
@@ -181,14 +169,14 @@ class PortMappings:
|
|
|
181
169
|
|
|
182
170
|
def add(
|
|
183
171
|
self,
|
|
184
|
-
port:
|
|
185
|
-
mapped:
|
|
172
|
+
port: int | PortRange,
|
|
173
|
+
mapped: int | PortRange = None,
|
|
186
174
|
protocol: PortProtocol = "tcp",
|
|
187
175
|
):
|
|
188
176
|
mapped = mapped or port
|
|
189
|
-
if
|
|
177
|
+
if isinstance(port, PortRange):
|
|
190
178
|
for i in range(port[1] - port[0] + 1):
|
|
191
|
-
if
|
|
179
|
+
if isinstance(mapped, PortRange):
|
|
192
180
|
self.add(port[0] + i, mapped[0] + i, protocol)
|
|
193
181
|
else:
|
|
194
182
|
self.add(port[0] + i, mapped, protocol)
|
|
@@ -266,7 +254,7 @@ class PortMappings:
|
|
|
266
254
|
|
|
267
255
|
return [item for k, v in self.mappings.items() for item in entry(k, v)]
|
|
268
256
|
|
|
269
|
-
def to_dict(self) -> dict[str,
|
|
257
|
+
def to_dict(self) -> dict[str, tuple[str, int | list[int]] | int]:
|
|
270
258
|
bind_address = self.bind_host or ""
|
|
271
259
|
|
|
272
260
|
def bind_port(bind_address, host_port):
|
|
@@ -452,27 +440,23 @@ class VolumeDirMount:
|
|
|
452
440
|
|
|
453
441
|
|
|
454
442
|
class VolumeMappings:
|
|
455
|
-
mappings: list[
|
|
443
|
+
mappings: list[SimpleVolumeBind | BindMount]
|
|
456
444
|
|
|
457
|
-
def __init__(self, mappings: list[
|
|
445
|
+
def __init__(self, mappings: list[SimpleVolumeBind | BindMount | VolumeDirMount] = None):
|
|
458
446
|
self.mappings = mappings if mappings is not None else []
|
|
459
447
|
|
|
460
|
-
def add(self, mapping:
|
|
448
|
+
def add(self, mapping: SimpleVolumeBind | BindMount | VolumeDirMount):
|
|
461
449
|
self.append(mapping)
|
|
462
450
|
|
|
463
451
|
def append(
|
|
464
452
|
self,
|
|
465
|
-
mapping:
|
|
466
|
-
SimpleVolumeBind,
|
|
467
|
-
BindMount,
|
|
468
|
-
VolumeDirMount,
|
|
469
|
-
],
|
|
453
|
+
mapping: SimpleVolumeBind | BindMount | VolumeDirMount,
|
|
470
454
|
):
|
|
471
455
|
self.mappings.append(mapping)
|
|
472
456
|
|
|
473
457
|
def find_target_mapping(
|
|
474
458
|
self, container_dir: str
|
|
475
|
-
) ->
|
|
459
|
+
) -> SimpleVolumeBind | BindMount | VolumeDirMount | None:
|
|
476
460
|
"""
|
|
477
461
|
Looks through the volumes and returns the one where the container dir matches ``container_dir``.
|
|
478
462
|
Returns None if there is no volume mapping to the given container directory.
|
|
@@ -511,8 +495,8 @@ class VolumeInfo(NamedTuple):
|
|
|
511
495
|
mode: str
|
|
512
496
|
rw: bool
|
|
513
497
|
propagation: str
|
|
514
|
-
name:
|
|
515
|
-
driver:
|
|
498
|
+
name: str | None = None
|
|
499
|
+
driver: str | None = None
|
|
516
500
|
|
|
517
501
|
|
|
518
502
|
@dataclasses.dataclass
|
|
@@ -524,13 +508,13 @@ class LogConfig:
|
|
|
524
508
|
@dataclasses.dataclass
|
|
525
509
|
class ContainerConfiguration:
|
|
526
510
|
image_name: str
|
|
527
|
-
name:
|
|
511
|
+
name: str | None = None
|
|
528
512
|
volumes: VolumeMappings = dataclasses.field(default_factory=VolumeMappings)
|
|
529
513
|
ports: PortMappings = dataclasses.field(default_factory=PortMappings)
|
|
530
514
|
exposed_ports: list[str] = dataclasses.field(default_factory=list)
|
|
531
|
-
entrypoint:
|
|
532
|
-
additional_flags:
|
|
533
|
-
command:
|
|
515
|
+
entrypoint: list[str] | str | None = None
|
|
516
|
+
additional_flags: str | None = None
|
|
517
|
+
command: list[str] | None = None
|
|
534
518
|
env_vars: dict[str, str] = dataclasses.field(default_factory=dict)
|
|
535
519
|
|
|
536
520
|
privileged: bool = False
|
|
@@ -539,19 +523,19 @@ class ContainerConfiguration:
|
|
|
539
523
|
tty: bool = False
|
|
540
524
|
detach: bool = False
|
|
541
525
|
|
|
542
|
-
stdin:
|
|
543
|
-
user:
|
|
544
|
-
cap_add:
|
|
545
|
-
cap_drop:
|
|
546
|
-
security_opt:
|
|
547
|
-
network:
|
|
548
|
-
dns:
|
|
549
|
-
workdir:
|
|
550
|
-
platform:
|
|
551
|
-
ulimits:
|
|
552
|
-
labels:
|
|
553
|
-
init:
|
|
554
|
-
log_config:
|
|
526
|
+
stdin: str | None = None
|
|
527
|
+
user: str | None = None
|
|
528
|
+
cap_add: list[str] | None = None
|
|
529
|
+
cap_drop: list[str] | None = None
|
|
530
|
+
security_opt: list[str] | None = None
|
|
531
|
+
network: str | None = None
|
|
532
|
+
dns: str | None = None
|
|
533
|
+
workdir: str | None = None
|
|
534
|
+
platform: str | None = None
|
|
535
|
+
ulimits: list[Ulimit] | None = None
|
|
536
|
+
labels: dict[str, str] | None = None
|
|
537
|
+
init: bool | None = None
|
|
538
|
+
log_config: LogConfig | None = None
|
|
555
539
|
|
|
556
540
|
|
|
557
541
|
class ContainerConfigurator(Protocol):
|
|
@@ -574,17 +558,17 @@ class DockerRunFlags:
|
|
|
574
558
|
create: https://docs.docker.com/engine/reference/commandline/create/
|
|
575
559
|
"""
|
|
576
560
|
|
|
577
|
-
env_vars:
|
|
578
|
-
extra_hosts:
|
|
579
|
-
labels:
|
|
580
|
-
volumes:
|
|
581
|
-
network:
|
|
582
|
-
platform:
|
|
583
|
-
privileged:
|
|
584
|
-
ports:
|
|
585
|
-
ulimits:
|
|
586
|
-
user:
|
|
587
|
-
dns:
|
|
561
|
+
env_vars: dict[str, str] | None
|
|
562
|
+
extra_hosts: dict[str, str] | None
|
|
563
|
+
labels: dict[str, str] | None
|
|
564
|
+
volumes: list[SimpleVolumeBind] | None
|
|
565
|
+
network: str | None
|
|
566
|
+
platform: DockerPlatform | None
|
|
567
|
+
privileged: bool | None
|
|
568
|
+
ports: PortMappings | None
|
|
569
|
+
ulimits: list[Ulimit] | None
|
|
570
|
+
user: str | None
|
|
571
|
+
dns: list[str] | None
|
|
588
572
|
|
|
589
573
|
|
|
590
574
|
class RegistryResolverStrategy(Protocol):
|
|
@@ -706,7 +690,7 @@ class ContainerClient(metaclass=ABCMeta):
|
|
|
706
690
|
"""
|
|
707
691
|
|
|
708
692
|
@abstractmethod
|
|
709
|
-
def list_containers(self, filter:
|
|
693
|
+
def list_containers(self, filter: list[str] | str | None = None, all=True) -> list[dict]:
|
|
710
694
|
"""List all containers matching the given filters
|
|
711
695
|
|
|
712
696
|
:return: A list of dicts with keys id, image, name, labels, status
|
|
@@ -729,7 +713,7 @@ class ContainerClient(metaclass=ABCMeta):
|
|
|
729
713
|
container_name,
|
|
730
714
|
file_contents: bytes,
|
|
731
715
|
container_path: str,
|
|
732
|
-
chmod_mode:
|
|
716
|
+
chmod_mode: int | None = None,
|
|
733
717
|
) -> None:
|
|
734
718
|
"""
|
|
735
719
|
Create a file in container with the provided content. Provide the 'chmod_mode' argument if you want the file to have specific permissions.
|
|
@@ -761,8 +745,8 @@ class ContainerClient(metaclass=ABCMeta):
|
|
|
761
745
|
def pull_image(
|
|
762
746
|
self,
|
|
763
747
|
docker_image: str,
|
|
764
|
-
platform:
|
|
765
|
-
log_handler:
|
|
748
|
+
platform: DockerPlatform | None = None,
|
|
749
|
+
log_handler: Callable[[str], None] | None = None,
|
|
766
750
|
) -> None:
|
|
767
751
|
"""
|
|
768
752
|
Pulls an image with a given name from a Docker registry
|
|
@@ -780,7 +764,7 @@ class ContainerClient(metaclass=ABCMeta):
|
|
|
780
764
|
dockerfile_path: str,
|
|
781
765
|
image_name: str,
|
|
782
766
|
context_path: str = None,
|
|
783
|
-
platform:
|
|
767
|
+
platform: DockerPlatform | None = None,
|
|
784
768
|
) -> str:
|
|
785
769
|
"""Builds an image from the given Dockerfile
|
|
786
770
|
|
|
@@ -824,7 +808,7 @@ class ContainerClient(metaclass=ABCMeta):
|
|
|
824
808
|
"""Returns a blocking generator you can iterate over to retrieve log output as it happens."""
|
|
825
809
|
|
|
826
810
|
@abstractmethod
|
|
827
|
-
def inspect_container(self, container_name_or_id: str) -> dict[str,
|
|
811
|
+
def inspect_container(self, container_name_or_id: str) -> dict[str, dict | str]:
|
|
828
812
|
"""Get detailed attributes of a container.
|
|
829
813
|
|
|
830
814
|
:return: Dict containing docker attributes as returned by the daemon
|
|
@@ -845,7 +829,7 @@ class ContainerClient(metaclass=ABCMeta):
|
|
|
845
829
|
@abstractmethod
|
|
846
830
|
def inspect_image(
|
|
847
831
|
self, image_name: str, pull: bool = True, strip_wellknown_repo_prefixes: bool = True
|
|
848
|
-
) -> dict[str,
|
|
832
|
+
) -> dict[str, dict | list | str]:
|
|
849
833
|
"""Get detailed attributes of an image.
|
|
850
834
|
|
|
851
835
|
:param image_name: Image name to inspect
|
|
@@ -871,7 +855,7 @@ class ContainerClient(metaclass=ABCMeta):
|
|
|
871
855
|
"""
|
|
872
856
|
|
|
873
857
|
@abstractmethod
|
|
874
|
-
def inspect_network(self, network_name: str) -> dict[str,
|
|
858
|
+
def inspect_network(self, network_name: str) -> dict[str, dict | str]:
|
|
875
859
|
"""Get detailed attributes of an network.
|
|
876
860
|
|
|
877
861
|
:return: Dict containing docker attributes as returned by the daemon
|
|
@@ -882,7 +866,7 @@ class ContainerClient(metaclass=ABCMeta):
|
|
|
882
866
|
self,
|
|
883
867
|
network_name: str,
|
|
884
868
|
container_name_or_id: str,
|
|
885
|
-
aliases:
|
|
869
|
+
aliases: list | None = None,
|
|
886
870
|
link_local_ips: list[str] = None,
|
|
887
871
|
) -> None:
|
|
888
872
|
"""
|
|
@@ -994,31 +978,31 @@ class ContainerClient(metaclass=ABCMeta):
|
|
|
994
978
|
self,
|
|
995
979
|
image_name: str,
|
|
996
980
|
*,
|
|
997
|
-
name:
|
|
998
|
-
entrypoint:
|
|
981
|
+
name: str | None = None,
|
|
982
|
+
entrypoint: list[str] | str | None = None,
|
|
999
983
|
remove: bool = False,
|
|
1000
984
|
interactive: bool = False,
|
|
1001
985
|
tty: bool = False,
|
|
1002
986
|
detach: bool = False,
|
|
1003
|
-
command:
|
|
1004
|
-
volumes:
|
|
1005
|
-
ports:
|
|
1006
|
-
exposed_ports:
|
|
1007
|
-
env_vars:
|
|
1008
|
-
user:
|
|
1009
|
-
cap_add:
|
|
1010
|
-
cap_drop:
|
|
1011
|
-
security_opt:
|
|
1012
|
-
network:
|
|
1013
|
-
dns:
|
|
1014
|
-
additional_flags:
|
|
1015
|
-
workdir:
|
|
1016
|
-
privileged:
|
|
1017
|
-
labels:
|
|
1018
|
-
platform:
|
|
1019
|
-
ulimits:
|
|
1020
|
-
init:
|
|
1021
|
-
log_config:
|
|
987
|
+
command: list[str] | str | None = None,
|
|
988
|
+
volumes: VolumeMappings | list[SimpleVolumeBind] | None = None,
|
|
989
|
+
ports: PortMappings | None = None,
|
|
990
|
+
exposed_ports: list[str] | None = None,
|
|
991
|
+
env_vars: dict[str, str] | None = None,
|
|
992
|
+
user: str | None = None,
|
|
993
|
+
cap_add: list[str] | None = None,
|
|
994
|
+
cap_drop: list[str] | None = None,
|
|
995
|
+
security_opt: list[str] | None = None,
|
|
996
|
+
network: str | None = None,
|
|
997
|
+
dns: str | list[str] | None = None,
|
|
998
|
+
additional_flags: str | None = None,
|
|
999
|
+
workdir: str | None = None,
|
|
1000
|
+
privileged: bool | None = None,
|
|
1001
|
+
labels: dict[str, str] | None = None,
|
|
1002
|
+
platform: DockerPlatform | None = None,
|
|
1003
|
+
ulimits: list[Ulimit] | None = None,
|
|
1004
|
+
init: bool | None = None,
|
|
1005
|
+
log_config: LogConfig | None = None,
|
|
1022
1006
|
) -> str:
|
|
1023
1007
|
"""Creates a container with the given image
|
|
1024
1008
|
|
|
@@ -1031,31 +1015,31 @@ class ContainerClient(metaclass=ABCMeta):
|
|
|
1031
1015
|
image_name: str,
|
|
1032
1016
|
stdin: bytes = None,
|
|
1033
1017
|
*,
|
|
1034
|
-
name:
|
|
1035
|
-
entrypoint:
|
|
1018
|
+
name: str | None = None,
|
|
1019
|
+
entrypoint: str | None = None,
|
|
1036
1020
|
remove: bool = False,
|
|
1037
1021
|
interactive: bool = False,
|
|
1038
1022
|
tty: bool = False,
|
|
1039
1023
|
detach: bool = False,
|
|
1040
|
-
command:
|
|
1041
|
-
volumes:
|
|
1042
|
-
ports:
|
|
1043
|
-
exposed_ports:
|
|
1044
|
-
env_vars:
|
|
1045
|
-
user:
|
|
1046
|
-
cap_add:
|
|
1047
|
-
cap_drop:
|
|
1048
|
-
security_opt:
|
|
1049
|
-
network:
|
|
1050
|
-
dns:
|
|
1051
|
-
additional_flags:
|
|
1052
|
-
workdir:
|
|
1053
|
-
labels:
|
|
1054
|
-
platform:
|
|
1055
|
-
privileged:
|
|
1056
|
-
ulimits:
|
|
1057
|
-
init:
|
|
1058
|
-
log_config:
|
|
1024
|
+
command: list[str] | str | None = None,
|
|
1025
|
+
volumes: VolumeMappings | list[SimpleVolumeBind] | None = None,
|
|
1026
|
+
ports: PortMappings | None = None,
|
|
1027
|
+
exposed_ports: list[str] | None = None,
|
|
1028
|
+
env_vars: dict[str, str] | None = None,
|
|
1029
|
+
user: str | None = None,
|
|
1030
|
+
cap_add: list[str] | None = None,
|
|
1031
|
+
cap_drop: list[str] | None = None,
|
|
1032
|
+
security_opt: list[str] | None = None,
|
|
1033
|
+
network: str | None = None,
|
|
1034
|
+
dns: str | None = None,
|
|
1035
|
+
additional_flags: str | None = None,
|
|
1036
|
+
workdir: str | None = None,
|
|
1037
|
+
labels: dict[str, str] | None = None,
|
|
1038
|
+
platform: DockerPlatform | None = None,
|
|
1039
|
+
privileged: bool | None = None,
|
|
1040
|
+
ulimits: list[Ulimit] | None = None,
|
|
1041
|
+
init: bool | None = None,
|
|
1042
|
+
log_config: LogConfig | None = None,
|
|
1059
1043
|
) -> tuple[bytes, bytes]:
|
|
1060
1044
|
"""Creates and runs a given docker container
|
|
1061
1045
|
|
|
@@ -1100,13 +1084,13 @@ class ContainerClient(metaclass=ABCMeta):
|
|
|
1100
1084
|
def exec_in_container(
|
|
1101
1085
|
self,
|
|
1102
1086
|
container_name_or_id: str,
|
|
1103
|
-
command:
|
|
1087
|
+
command: list[str] | str,
|
|
1104
1088
|
interactive: bool = False,
|
|
1105
1089
|
detach: bool = False,
|
|
1106
|
-
env_vars:
|
|
1107
|
-
stdin:
|
|
1108
|
-
user:
|
|
1109
|
-
workdir:
|
|
1090
|
+
env_vars: dict[str, str | None] | None = None,
|
|
1091
|
+
stdin: bytes | None = None,
|
|
1092
|
+
user: str | None = None,
|
|
1093
|
+
workdir: str | None = None,
|
|
1110
1094
|
) -> tuple[bytes, bytes]:
|
|
1111
1095
|
"""Execute a given command in a container
|
|
1112
1096
|
|
|
@@ -1120,7 +1104,7 @@ class ContainerClient(metaclass=ABCMeta):
|
|
|
1120
1104
|
stdin: bytes = None,
|
|
1121
1105
|
interactive: bool = False,
|
|
1122
1106
|
attach: bool = False,
|
|
1123
|
-
flags:
|
|
1107
|
+
flags: str | None = None,
|
|
1124
1108
|
) -> tuple[bytes, bytes]:
|
|
1125
1109
|
"""Start a given, already created container
|
|
1126
1110
|
|
|
@@ -1134,7 +1118,7 @@ class ContainerClient(metaclass=ABCMeta):
|
|
|
1134
1118
|
"""
|
|
1135
1119
|
|
|
1136
1120
|
@abstractmethod
|
|
1137
|
-
def login(self, username: str, password: str, registry:
|
|
1121
|
+
def login(self, username: str, password: str, registry: str | None = None) -> None:
|
|
1138
1122
|
"""
|
|
1139
1123
|
Login into an OCI registry
|
|
1140
1124
|
|
|
@@ -1153,13 +1137,13 @@ class Util:
|
|
|
1153
1137
|
MAX_ENV_ARGS_LENGTH = 20000
|
|
1154
1138
|
|
|
1155
1139
|
@staticmethod
|
|
1156
|
-
def format_env_vars(key: str, value:
|
|
1140
|
+
def format_env_vars(key: str, value: str | None):
|
|
1157
1141
|
if value is None:
|
|
1158
1142
|
return key
|
|
1159
1143
|
return f"{key}={value}"
|
|
1160
1144
|
|
|
1161
1145
|
@classmethod
|
|
1162
|
-
def create_env_vars_file_flag(cls, env_vars: dict) -> tuple[list[str],
|
|
1146
|
+
def create_env_vars_file_flag(cls, env_vars: dict) -> tuple[list[str], str | None]:
|
|
1163
1147
|
if not env_vars:
|
|
1164
1148
|
return [], None
|
|
1165
1149
|
result = []
|
|
@@ -1292,16 +1276,16 @@ class Util:
|
|
|
1292
1276
|
@staticmethod
|
|
1293
1277
|
def parse_additional_flags(
|
|
1294
1278
|
additional_flags: str,
|
|
1295
|
-
env_vars:
|
|
1296
|
-
labels:
|
|
1297
|
-
volumes:
|
|
1298
|
-
network:
|
|
1299
|
-
platform:
|
|
1300
|
-
ports:
|
|
1301
|
-
privileged:
|
|
1302
|
-
user:
|
|
1303
|
-
ulimits:
|
|
1304
|
-
dns:
|
|
1279
|
+
env_vars: dict[str, str] | None = None,
|
|
1280
|
+
labels: dict[str, str] | None = None,
|
|
1281
|
+
volumes: list[SimpleVolumeBind] | None = None,
|
|
1282
|
+
network: str | None = None,
|
|
1283
|
+
platform: DockerPlatform | None = None,
|
|
1284
|
+
ports: PortMappings | None = None,
|
|
1285
|
+
privileged: bool | None = None,
|
|
1286
|
+
user: str | None = None,
|
|
1287
|
+
ulimits: list[Ulimit] | None = None,
|
|
1288
|
+
dns: str | list[str] | None = None,
|
|
1305
1289
|
) -> DockerRunFlags:
|
|
1306
1290
|
"""Parses additional CLI-formatted Docker flags, which could overwrite provided defaults.
|
|
1307
1291
|
:param additional_flags: String which contains the flag definitions inspired by the Docker CLI reference:
|
|
@@ -1522,7 +1506,7 @@ class Util:
|
|
|
1522
1506
|
|
|
1523
1507
|
@staticmethod
|
|
1524
1508
|
def convert_mount_list_to_dict(
|
|
1525
|
-
volumes:
|
|
1509
|
+
volumes: list[SimpleVolumeBind] | VolumeMappings,
|
|
1526
1510
|
) -> dict[str, dict[str, str]]:
|
|
1527
1511
|
"""Converts a List of (host_path, container_path) tuples to a Dict suitable as volume argument for docker sdk"""
|
|
1528
1512
|
|