Add types to docker/context (#11818)

This commit is contained in:
kasium
2024-04-29 14:27:55 +02:00
committed by GitHub
parent 6dc9187625
commit 78a86de5d9
2 changed files with 55 additions and 27 deletions

View File

@@ -1,5 +1,4 @@
from _typeshed import Incomplete
from collections.abc import Mapping, Sequence
from collections.abc import Sequence
from docker.context.context import Context
from docker.tls import TLSConfig
@@ -27,4 +26,4 @@ class ContextAPI:
@classmethod
def remove_context(cls, name: str) -> None: ...
@classmethod
def inspect_context(cls, name: str = "default") -> Mapping[str, Incomplete]: ...
def inspect_context(cls, name: str = "default") -> Context: ...

View File

@@ -1,47 +1,76 @@
from _typeshed import Incomplete
from collections.abc import Mapping
from typing import Any, TypedDict, type_check_only
@type_check_only
class _StorageData(TypedDict):
MetadataPath: str
TLSPath: str
@type_check_only
class _Storage(TypedDict):
Storage: _StorageData
@type_check_only
class _Endpoint(TypedDict, total=False):
Host: str
SkipTLSVerify: bool
@type_check_only
class _TLSMaterial:
TLSMaterial: dict[str, list[str]]
@type_check_only
class _MetaMetaData(TypedDict, total=False):
StackOrchestrator: str
@type_check_only
class _Metadata(TypedDict):
Name: str
Metadata: _MetaMetaData
Endpoints: Mapping[str, _Endpoint]
class Context:
name: Incomplete
context_type: Incomplete
orchestrator: Incomplete
endpoints: Incomplete
tls_cfg: Incomplete
name: str
context_type: str | None
orchestrator: str | None
endpoints: dict[str, _Endpoint]
tls_cfg: dict[str, Any]
meta_path: str
tls_path: str
def __init__(
self,
name,
orchestrator: Incomplete | None = None,
host: Incomplete | None = None,
endpoints: Incomplete | None = None,
name: str,
orchestrator: str | None = None,
host: str | None = None,
endpoints: Mapping[str, _Endpoint] | None = None,
tls: bool = False,
) -> None: ...
def set_endpoint(
self,
name: str = "docker",
host: Incomplete | None = None,
tls_cfg: Incomplete | None = None,
host: str | None = None,
tls_cfg: Mapping[str, Any] | None = None,
skip_tls_verify: bool = False,
def_namespace: Incomplete | None = None,
def_namespace: str | None = None,
) -> None: ...
def inspect(self): ...
def inspect(self) -> Mapping[str, Any]: ...
@classmethod
def load_context(cls, name): ...
def load_context(cls, name: str) -> Context | None: ...
def save(self) -> None: ...
def remove(self) -> None: ...
def __call__(self): ...
def is_docker_host(self): ...
def __call__(self) -> Mapping[str, Any]: ...
def is_docker_host(self) -> bool: ...
@property
def Name(self): ...
def Name(self) -> str: ...
@property
def Host(self): ...
def Host(self) -> str | None: ...
@property
def Orchestrator(self): ...
def Orchestrator(self) -> str: ...
@property
def Metadata(self): ...
def Metadata(self) -> _Metadata: ...
@property
def TLSConfig(self): ...
def TLSConfig(self) -> Any: ...
@property
def TLSMaterial(self): ...
def TLSMaterial(self) -> _TLSMaterial: ...
@property
def Storage(self): ...
def Storage(self) -> _Storage: ...