Skip to content

Commit

Permalink
Fix Pod property type annotations to allow for missing fields in insp…
Browse files Browse the repository at this point in the history
…ect output
  • Loading branch information
LewisGaul committed Oct 30, 2024
1 parent b590c97 commit 141eb5b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
26 changes: 13 additions & 13 deletions python_on_whales/components/pod/cli_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,59 +96,59 @@ def created(self) -> datetime:
return self._get_inspect_result().created

@property
def create_command(self) -> List[str]:
def create_command(self) -> Optional[List[str]]:
return self._get_inspect_result().create_command

@property
def exit_policy(self) -> str:
def exit_policy(self) -> Optional[str]:
return self._get_inspect_result().exit_policy

@property
def state(self) -> str:
def state(self) -> Optional[str]:
return self._get_inspect_result().state

@property
def hostname(self) -> str:
def hostname(self) -> Optional[str]:
return self._get_inspect_result().hostname

@property
def labels(self) -> Mapping[str, str]:
return self._get_inspect_result().labels

@property
def create_cgroup(self) -> bool:
def create_cgroup(self) -> Optional[bool]:
return self._get_inspect_result().create_cgroup

@property
def cgroup_parent(self) -> str:
def cgroup_parent(self) -> Optional[str]:
return self._get_inspect_result().cgroup_parent

@property
def cgroup_path(self) -> str:
def cgroup_path(self) -> Optional[str]:
return self._get_inspect_result().cgroup_path

@property
def create_infra(self) -> bool:
def create_infra(self) -> Optional[bool]:
return self._get_inspect_result().create_infra

@property
def infra_container_id(self) -> str:
def infra_container_id(self) -> Optional[str]:
return self._get_inspect_result().infra_container_id

@property
def infra_config(self) -> PodInfraConfig:
def infra_config(self) -> Optional[PodInfraConfig]:
return self._get_inspect_result().infra_config

@property
def shared_namespaces(self) -> List[str]:
def shared_namespaces(self) -> Optional[List[str]]:
return self._get_inspect_result().shared_namespaces

@property
def num_containers(self) -> int:
def num_containers(self) -> Optional[int]:
return self._get_inspect_result().num_containers

@property
def containers(self) -> List[PodContainer]:
def containers(self) -> Optional[List[PodContainer]]:
return self._get_inspect_result().containers

def __repr__(self):
Expand Down
6 changes: 4 additions & 2 deletions python_on_whales/components/pod/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from datetime import datetime
from typing import List, Mapping, Optional
from typing import Annotated, List, Mapping, Optional

import pydantic

from python_on_whales.components.container.models import PortBinding
from python_on_whales.utils import DockerCamelModel
Expand Down Expand Up @@ -32,7 +34,7 @@ class PodContainer(DockerCamelModel):
class PodInspectResult(DockerCamelModel):
id: Optional[str] = None
name: Optional[str] = None
created: Optional[datetime] = None
created: Annotated[Optional[datetime], pydantic.Field(alias="CreatedAt")] = None
create_command: Optional[List[str]] = None
exit_policy: Optional[str] = None
state: Optional[str] = None
Expand Down

0 comments on commit 141eb5b

Please sign in to comment.