fix: extension-fields parse error from compose spec #48

This commit is contained in:
Zheng Zhi Yuan 2023-05-03 16:50:39 +08:00
parent 9cb6baaa03
commit e902237356

View file

@ -1,6 +1,6 @@
# generated by datamodel-codegen: # generated by datamodel-codegen:
# filename: compose-spec.json # filename: compose-spec.json
# timestamp: 2023-01-10T13:17:45+00:00 # timestamp: 2023-05-03T07:42:00+00:00
from __future__ import annotations from __future__ import annotations
@ -17,7 +17,7 @@ class Cgroup(YamlStrEnum):
class CredentialSpec(YamlModel): class CredentialSpec(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
config: Optional[str] = None config: Optional[str] = None
file: Optional[str] = None file: Optional[str] = None
@ -32,14 +32,15 @@ class Condition(YamlStrEnum):
class DependsOn(YamlModel): class DependsOn(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
restart: Optional[bool] = None
condition: Condition condition: Condition
class Extend(YamlModel): class Extend(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
service: str service: str
file: Optional[str] = None file: Optional[str] = None
@ -47,15 +48,15 @@ class Extend(YamlModel):
class Logging(YamlModel): class Logging(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
driver: Optional[str] = None driver: Optional[str] = None
options: Optional[Dict[constr(regex=r"^.+$"), Optional[Union[str, float]]]] = None # type: ignore # noqa: F722 options: Optional[Dict[constr(regex=r"^.+$"), Optional[Union[str, float]]]] = None
class Port(YamlModel): class Port(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
mode: Optional[str] = None mode: Optional[str] = None
host_ip: Optional[str] = None host_ip: Optional[str] = None
@ -74,7 +75,7 @@ class PullPolicy(YamlStrEnum):
class Ulimit(YamlModel): class Ulimit(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
hard: int hard: int
soft: int soft: int
@ -87,7 +88,7 @@ class Selinux(YamlStrEnum):
class Bind(YamlModel): class Bind(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
propagation: Optional[str] = None propagation: Optional[str] = None
create_host_path: Optional[bool] = None create_host_path: Optional[bool] = None
@ -96,22 +97,22 @@ class Bind(YamlModel):
class AdditionalVolumeOption(YamlModel): class AdditionalVolumeOption(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
nocopy: Optional[bool] = None nocopy: Optional[bool] = None
class Tmpfs(YamlModel): class Tmpfs(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
size: Optional[Union[conint(ge=0), str]] = None # type: ignore size: Optional[Union[conint(ge=0), str]] = None
mode: Optional[float] = None mode: Optional[float] = None
class ServiceVolume(YamlModel): class ServiceVolume(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
type: str type: str
source: Optional[str] = None source: Optional[str] = None
@ -125,7 +126,7 @@ class ServiceVolume(YamlModel):
class Healthcheck(YamlModel): class Healthcheck(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
disable: Optional[bool] = None disable: Optional[bool] = None
interval: Optional[str] = None interval: Optional[str] = None
@ -142,7 +143,7 @@ class Order(YamlStrEnum):
class RollbackConfig(YamlModel): class RollbackConfig(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
parallelism: Optional[int] = None parallelism: Optional[int] = None
delay: Optional[str] = None delay: Optional[str] = None
@ -151,15 +152,13 @@ class RollbackConfig(YamlModel):
max_failure_ratio: Optional[float] = None max_failure_ratio: Optional[float] = None
order: Optional[Order] = None order: Optional[Order] = None
class ConfigOrder(YamlStrEnum): class ConfigOrder(YamlStrEnum):
start_first = "start-first" start_first = "start-first"
stop_first = "stop-first" stop_first = "stop-first"
class UpdateConfig(YamlModel): class UpdateConfig(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
parallelism: Optional[int] = None parallelism: Optional[int] = None
delay: Optional[str] = None delay: Optional[str] = None
@ -171,7 +170,7 @@ class UpdateConfig(YamlModel):
class Limits(YamlModel): class Limits(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
cpus: Optional[Union[float, str]] = None cpus: Optional[Union[float, str]] = None
memory: Optional[str] = None memory: Optional[str] = None
@ -180,7 +179,7 @@ class Limits(YamlModel):
class RestartPolicy(YamlModel): class RestartPolicy(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
condition: Optional[str] = None condition: Optional[str] = None
delay: Optional[str] = None delay: Optional[str] = None
@ -190,14 +189,14 @@ class RestartPolicy(YamlModel):
class Preference(YamlModel): class Preference(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
spread: Optional[str] = None spread: Optional[str] = None
class Placement(YamlModel): class Placement(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
constraints: Optional[List[str]] = None constraints: Optional[List[str]] = None
preferences: Optional[List[Preference]] = None preferences: Optional[List[Preference]] = None
@ -206,7 +205,7 @@ class Placement(YamlModel):
class DiscreteResourceSpec(YamlModel): class DiscreteResourceSpec(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
kind: Optional[str] = None kind: Optional[str] = None
value: Optional[float] = None value: Optional[float] = None
@ -214,48 +213,49 @@ class DiscreteResourceSpec(YamlModel):
class GenericResource(YamlModel): class GenericResource(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
discrete_resource_spec: Optional[DiscreteResourceSpec] = None discrete_resource_spec: Optional[DiscreteResourceSpec] = None
class GenericResources(YamlModel): class GenericResources(YamlModel):
class Config:
extra = Extra.allow
__root__: List[GenericResource] __root__: List[GenericResource]
class ConfigItem(YamlModel): class ConfigItem(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
subnet: Optional[str] = None subnet: Optional[str] = None
ip_range: Optional[str] = None ip_range: Optional[str] = None
gateway: Optional[str] = None gateway: Optional[str] = None
aux_addresses: Optional[Dict[constr(regex=r"^.+$"), str]] = None # type: ignore # noqa: F722 aux_addresses: Optional[Dict[constr(regex=r"^.+$"), str]] = None
class Ipam(YamlModel): class Ipam(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
driver: Optional[str] = None driver: Optional[str] = None
config: Optional[List[ConfigItem]] = None config: Optional[List[ConfigItem]] = None
options: Optional[Dict[constr(regex=r"^.+$"), str]] = None # type: ignore # noqa: F722 options: Optional[Dict[constr(regex=r"^.+$"), str]] = None
class ExternalNetwork(YamlModel): class ExternalNetwork(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
name: Optional[str] = None name: Optional[str] = None
class ExternalVolume(YamlModel): class ExternalVolume(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
name: Optional[str] = None name: Optional[str] = None
class ExternalSecret(YamlModel): class ExternalSecret(YamlModel):
name: Optional[str] = None name: Optional[str] = None
@ -263,20 +263,25 @@ class ExternalSecret(YamlModel):
class ExternalConfig(YamlModel): class ExternalConfig(YamlModel):
name: Optional[str] = None name: Optional[str] = None
class ListOfStrings(YamlModel): class ListOfStrings(YamlModel):
class Config:
extra = Extra.allow
__root__: List[str] = Field(..., unique_items=True) __root__: List[str] = Field(..., unique_items=True)
class ListOrDict(YamlModel): class ListOrDict(YamlModel):
class Config:
extra = Extra.allow
__root__: Union[ __root__: Union[
Dict[constr(regex=r".+"), Optional[Union[str, float, bool]]], List[str] # type: ignore # noqa: F722 Dict[constr(regex=r".+"), Optional[Union[str, float, bool]]], List[str]
] ]
class BlkioLimit(YamlModel): class BlkioLimit(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
path: Optional[str] = None path: Optional[str] = None
rate: Optional[Union[int, str]] = None rate: Optional[Union[int, str]] = None
@ -284,7 +289,7 @@ class BlkioLimit(YamlModel):
class BlkioWeight(YamlModel): class BlkioWeight(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
path: Optional[str] = None path: Optional[str] = None
weight: Optional[int] = None weight: Optional[int] = None
@ -292,7 +297,7 @@ class BlkioWeight(YamlModel):
class ServiceConfigOrSecretItem(YamlModel): class ServiceConfigOrSecretItem(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
source: Optional[str] = None source: Optional[str] = None
target: Optional[str] = None target: Optional[str] = None
@ -302,25 +307,33 @@ class ServiceConfigOrSecretItem(YamlModel):
class ServiceConfigOrSecret(YamlModel): class ServiceConfigOrSecret(YamlModel):
class Config:
extra = Extra.allow
__root__: List[Union[str, ServiceConfigOrSecretItem]] __root__: List[Union[str, ServiceConfigOrSecretItem]]
class Constraints(YamlModel): class Constraints(YamlModel):
class Config:
extra = Extra.allow
__root__: Any __root__: Any
class BuildItem(YamlModel): class BuildItem(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
context: Optional[str] = None context: Optional[str] = None
dockerfile: Optional[str] = None dockerfile: Optional[str] = None
dockerfile_inline: Optional[str] = None
args: Optional[ListOrDict] = None args: Optional[ListOrDict] = None
ssh: Optional[ListOrDict] = None ssh: Optional[ListOrDict] = None
labels: Optional[ListOrDict] = None labels: Optional[ListOrDict] = None
cache_from: Optional[List[str]] = None cache_from: Optional[List[str]] = None
cache_to: Optional[List[str]] = None cache_to: Optional[List[str]] = None
no_cache: Optional[bool] = None no_cache: Optional[bool] = None
additional_contexts: Optional[ListOrDict] = None
network: Optional[str] = None network: Optional[str] = None
pull: Optional[bool] = None pull: Optional[bool] = None
target: Optional[str] = None target: Optional[str] = None
@ -335,7 +348,7 @@ class BuildItem(YamlModel):
class BlkioConfig(YamlModel): class BlkioConfig(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
device_read_bps: Optional[List[BlkioLimit]] = None device_read_bps: Optional[List[BlkioLimit]] = None
device_read_iops: Optional[List[BlkioLimit]] = None device_read_iops: Optional[List[BlkioLimit]] = None
@ -347,7 +360,7 @@ class BlkioConfig(YamlModel):
class ServiceNetwork(YamlModel): class ServiceNetwork(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
aliases: Optional[ListOfStrings] = None aliases: Optional[ListOfStrings] = None
ipv4_address: Optional[str] = None ipv4_address: Optional[str] = None
@ -358,7 +371,7 @@ class ServiceNetwork(YamlModel):
class Device(YamlModel): class Device(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
capabilities: Optional[ListOfStrings] = None capabilities: Optional[ListOfStrings] = None
count: Optional[Union[str, int]] = None count: Optional[Union[str, int]] = None
@ -368,18 +381,21 @@ class Device(YamlModel):
class Devices(YamlModel): class Devices(YamlModel):
class Config:
extra = Extra.allow
__root__: List[Device] __root__: List[Device]
class Network(YamlModel): class Network(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
name: Optional[str] = None name: Optional[str] = None
driver: Optional[str] = None driver: Optional[str] = None
driver_opts: Optional[Dict[constr(regex=r"^.+$"), Union[str, float]]] = None # type: ignore # noqa: F722 driver_opts: Optional[Dict[constr(regex=r"^.+$"), Union[str, float]]] = None
ipam: Optional[Ipam] = None ipam: Optional[Ipam] = None
external: Optional[bool | ExternalNetwork] = None external: Optional[ExternalNetwork] = None
internal: Optional[bool] = None internal: Optional[bool] = None
enable_ipv6: Optional[bool] = None enable_ipv6: Optional[bool] = None
attachable: Optional[bool] = None attachable: Optional[bool] = None
@ -388,18 +404,18 @@ class Network(YamlModel):
class Volume(YamlModel): class Volume(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
name: Optional[str] = None name: Optional[str] = None
driver: Optional[str] = None driver: Optional[str] = None
driver_opts: Optional[Dict[constr(regex=r"^.+$"), Union[str, float]]] = None # type: ignore # noqa: F722 driver_opts: Optional[Dict[constr(regex=r"^.+$"), Union[str, float]]] = None
external: Optional[ExternalVolume] = None external: Optional[ExternalVolume] = None
labels: Optional[ListOrDict] = None labels: Optional[ListOrDict] = None
class Secret(YamlModel): class Secret(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
name: Optional[str] = None name: Optional[str] = None
environment: Optional[str] = None environment: Optional[str] = None
@ -407,13 +423,13 @@ class Secret(YamlModel):
external: Optional[ExternalSecret] = None external: Optional[ExternalSecret] = None
labels: Optional[ListOrDict] = None labels: Optional[ListOrDict] = None
driver: Optional[str] = None driver: Optional[str] = None
driver_opts: Optional[Dict[constr(regex=r"^.+$"), Union[str, float]]] = None # type: ignore # noqa: F722 driver_opts: Optional[Dict[constr(regex=r"^.+$"), Union[str, float]]] = None
template_driver: Optional[str] = None template_driver: Optional[str] = None
class Config(YamlModel): class Config(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
name: Optional[str] = None name: Optional[str] = None
file: Optional[str] = None file: Optional[str] = None
@ -423,12 +439,15 @@ class Config(YamlModel):
class StringOrList(YamlModel): class StringOrList(YamlModel):
class Config:
extra = Extra.allow
__root__: Union[str, ListOfStrings] __root__: Union[str, ListOfStrings]
class Reservations(YamlModel): class Reservations(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
cpus: Optional[Union[float, str]] = None cpus: Optional[Union[float, str]] = None
memory: Optional[str] = None memory: Optional[str] = None
@ -438,7 +457,7 @@ class Reservations(YamlModel):
class Resources(YamlModel): class Resources(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
limits: Optional[Limits] = None limits: Optional[Limits] = None
reservations: Optional[Reservations] = None reservations: Optional[Reservations] = None
@ -446,7 +465,7 @@ class Resources(YamlModel):
class Deployment(YamlModel): class Deployment(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
mode: Optional[str] = None mode: Optional[str] = None
endpoint_mode: Optional[str] = None endpoint_mode: Optional[str] = None
@ -461,7 +480,7 @@ class Deployment(YamlModel):
class Service(YamlModel): class Service(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
deploy: Optional[Deployment] = None deploy: Optional[Deployment] = None
build: Optional[Union[str, BuildItem]] = None build: Optional[Union[str, BuildItem]] = None
@ -470,11 +489,11 @@ class Service(YamlModel):
cap_drop: Optional[List[str]] = Field(None, unique_items=True) cap_drop: Optional[List[str]] = Field(None, unique_items=True)
cgroup: Optional[Cgroup] = None cgroup: Optional[Cgroup] = None
cgroup_parent: Optional[str] = None cgroup_parent: Optional[str] = None
command: Optional[Union[str, List[str]]] = None command: Optional[ExternalVolume] = None
configs: Optional[ServiceConfigOrSecret] = None configs: Optional[ServiceConfigOrSecret] = None
container_name: Optional[str] = None container_name: Optional[str] = None
cpu_count: Optional[conint(ge=0)] = None # type: ignore cpu_count: Optional[conint(ge=0)] = None
cpu_percent: Optional[conint(ge=0, le=100)] = None # type: ignore cpu_percent: Optional[conint(ge=0, le=100)] = None
cpu_shares: Optional[Union[float, str]] = None cpu_shares: Optional[Union[float, str]] = None
cpu_quota: Optional[Union[float, str]] = None cpu_quota: Optional[Union[float, str]] = None
cpu_period: Optional[Union[float, str]] = None cpu_period: Optional[Union[float, str]] = None
@ -484,7 +503,7 @@ class Service(YamlModel):
cpuset: Optional[str] = None cpuset: Optional[str] = None
credential_spec: Optional[CredentialSpec] = None credential_spec: Optional[CredentialSpec] = None
depends_on: Optional[ depends_on: Optional[
Union[ListOfStrings, Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), DependsOn]] # type: ignore # noqa: F722, E501 Union[ListOfStrings, Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), DependsOn]]
] = None ] = None
device_cgroup_rules: Optional[ListOfStrings] = None device_cgroup_rules: Optional[ListOfStrings] = None
devices: Optional[List[str]] = Field(None, unique_items=True) devices: Optional[List[str]] = Field(None, unique_items=True)
@ -492,7 +511,7 @@ class Service(YamlModel):
dns_opt: Optional[List[str]] = Field(None, unique_items=True) dns_opt: Optional[List[str]] = Field(None, unique_items=True)
dns_search: Optional[StringOrList] = None dns_search: Optional[StringOrList] = None
domainname: Optional[str] = None domainname: Optional[str] = None
entrypoint: Optional[Union[str, List[str]]] = None entrypoint: Optional[ExternalVolume] = None
env_file: Optional[StringOrList] = None env_file: Optional[StringOrList] = None
environment: Optional[ListOrDict] = None environment: Optional[ListOrDict] = None
expose: Optional[List[Union[str, float]]] = Field(None, unique_items=True) expose: Optional[List[Union[str, float]]] = Field(None, unique_items=True)
@ -517,11 +536,11 @@ class Service(YamlModel):
network_mode: Optional[str] = None network_mode: Optional[str] = None
networks: Optional[ networks: Optional[
Union[ Union[
ListOfStrings, Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), Optional[ServiceNetwork]] # type: ignore # noqa: F722, E501 ListOfStrings, Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), Optional[ServiceNetwork]]
] ]
] = None ] = None
oom_kill_disable: Optional[bool] = None oom_kill_disable: Optional[bool] = None
oom_score_adj: Optional[conint(ge=-1000, le=1000)] = None # type: ignore oom_score_adj: Optional[conint(ge=-1000, le=1000)] = None
pid: Optional[str] = None pid: Optional[str] = None
pids_limit: Optional[Union[float, str]] = None pids_limit: Optional[Union[float, str]] = None
platform: Optional[str] = None platform: Optional[str] = None
@ -543,26 +562,30 @@ class Service(YamlModel):
storage_opt: Optional[Dict[str, Any]] = None storage_opt: Optional[Dict[str, Any]] = None
tmpfs: Optional[StringOrList] = None tmpfs: Optional[StringOrList] = None
tty: Optional[bool] = None tty: Optional[bool] = None
ulimits: Optional[Dict[constr(regex=r"^[a-z]+$"), Union[int, Ulimit]]] = None # type: ignore # noqa: F722 ulimits: Optional[Dict[constr(regex=r"^[a-z]+$"), Union[int, Ulimit]]] = None
user: Optional[str] = None user: Optional[str] = None
uts: Optional[str] = None uts: Optional[str] = None
userns_mode: Optional[str] = None userns_mode: Optional[str] = None
volumes: Optional[List[Union[str, ServiceVolume]]] = Field(None, unique_items=True) volumes: Optional[List[Union[str, AdditionalVolumeOption]]] = Field(None, unique_items=True)
volumes_from: Optional[List[str]] = Field(None, unique_items=True) volumes_from: Optional[List[str]] = Field(None, unique_items=True)
working_dir: Optional[str] = None working_dir: Optional[str] = None
class ComposeSpecification(YamlModel): class ComposeSpecification(YamlModel):
class Config: class Config:
extra = Extra.forbid extra = Extra.allow
version: Optional[str] = Field(None, description="declared for backward compatibility, ignored.") version: Optional[str] = Field(
name: Optional[str] = Field( None, description="declared for backward compatibility, ignored."
)
name: Optional[constr(regex=r"^[a-z0-9][a-z0-9_-]*$")] = Field(
None, None,
description="define the Compose project name, until user defines one explicitly.", description="define the Compose project name, until user defines one explicitly.",
) )
services: Optional[Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), Service]] = None # type: ignore # noqa: F722 services: Optional[Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), Service]] = None
networks: Optional[Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), Optional[Network]]] = None # type: ignore # noqa: F722 networks: Optional[
volumes: Optional[Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), Optional[Volume]]] = None # type: ignore # noqa: F722 Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), Optional[Network]]
secrets: Optional[Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), Secret]] = None # type: ignore # noqa: F722 ] = None
configs: Optional[Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), Config]] = None # type: ignore # noqa: F722 volumes: Optional[Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), Optional[Volume]]] = None
secrets: Optional[Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), Secret]] = None
configs: Optional[Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), Config]] = None