From 389c5252c48f602b692adb72af5152a8174bcd91 Mon Sep 17 00:00:00 2001 From: Xyphuz Date: Tue, 10 Jan 2023 21:33:08 +0800 Subject: [PATCH] chore: update compose spec --- compose_viz/spec/compose-spec.json | 7 ++++- compose_viz/spec/compose_spec.py | 41 +++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/compose_viz/spec/compose-spec.json b/compose_viz/spec/compose-spec.json index d83dc2d..6f82797 100644 --- a/compose_viz/spec/compose-spec.json +++ b/compose_viz/spec/compose-spec.json @@ -102,8 +102,10 @@ "shm_size": {"type": ["integer", "string"]}, "extra_hosts": {"$ref": "#/definitions/list_or_dict"}, "isolation": {"type": "string"}, + "privileged": {"type": "boolean"}, "secrets": {"$ref": "#/definitions/service_config_or_secret"}, - "tags":{"type": "array", "items": {"type": "string"}} + "tags": {"type": "array", "items": {"type": "string"}}, + "platforms": {"type": "array", "items": {"type": "string"}} }, "additionalProperties": false, "patternProperties": {"^x-": {}} @@ -139,6 +141,7 @@ }, "cap_add": {"type": "array", "items": {"type": "string"}, "uniqueItems": true}, "cap_drop": {"type": "array", "items": {"type": "string"}, "uniqueItems": true}, + "cgroup": {"type": "string", "enum": ["host", "private"]}, "cgroup_parent": {"type": "string"}, "command": { "oneOf": [ @@ -364,6 +367,7 @@ } }, "user": {"type": "string"}, + "uts": {"type": "string"}, "userns_mode": {"type": "string"}, "volumes": { "type": "array", @@ -686,6 +690,7 @@ "type": "object", "properties": { "name": {"type": "string"}, + "environment": {"type": "string"}, "file": {"type": "string"}, "external": { "type": ["boolean", "object"], diff --git a/compose_viz/spec/compose_spec.py b/compose_viz/spec/compose_spec.py index 24caa0b..9c86710 100644 --- a/compose_viz/spec/compose_spec.py +++ b/compose_viz/spec/compose_spec.py @@ -1,14 +1,18 @@ # generated by datamodel-codegen: # filename: compose-spec.json -# timestamp: 2022-05-27T05:44:40+00:00 +# timestamp: 2023-01-10T13:17:45+00:00 from __future__ import annotations -from enum import Enum from typing import Any, Dict, List, Optional, Union from pydantic import Extra, Field, conint, constr -from pydantic_yaml import YamlModel +from pydantic_yaml import YamlModel, YamlStrEnum + + +class Cgroup(YamlStrEnum): + host = "host" + private = "private" class CredentialSpec(YamlModel): @@ -20,7 +24,7 @@ class CredentialSpec(YamlModel): registry: Optional[str] = None -class Condition(Enum): +class Condition(YamlStrEnum): service_started = "service_started" service_healthy = "service_healthy" service_completed_successfully = "service_completed_successfully" @@ -60,7 +64,7 @@ class Port(YamlModel): protocol: Optional[str] = None -class PullPolicy(Enum): +class PullPolicy(YamlStrEnum): always = "always" never = "never" if_not_present = "if_not_present" @@ -76,7 +80,7 @@ class Ulimit(YamlModel): soft: int -class Selinux(Enum): +class Selinux(YamlStrEnum): z = "z" Z = "Z" @@ -131,7 +135,7 @@ class Healthcheck(YamlModel): start_period: Optional[str] = None -class Order(Enum): +class Order(YamlStrEnum): start_first = "start-first" stop_first = "stop-first" @@ -148,7 +152,7 @@ class RollbackConfig(YamlModel): order: Optional[Order] = None -class ConfigOrder(Enum): +class ConfigOrder(YamlStrEnum): start_first = "start-first" stop_first = "stop-first" @@ -265,7 +269,9 @@ class ListOfStrings(YamlModel): class ListOrDict(YamlModel): - __root__: Union[Dict[constr(regex=r".+"), Optional[Union[str, float, bool]]], List[str]] # type: ignore # noqa: F722, E501 + __root__: Union[ + Dict[constr(regex=r".+"), Optional[Union[str, float, bool]]], List[str] # type: ignore # noqa: F722 + ] class BlkioLimit(YamlModel): @@ -321,8 +327,10 @@ class BuildItem(YamlModel): shm_size: Optional[Union[int, str]] = None extra_hosts: Optional[ListOrDict] = None isolation: Optional[str] = None + privileged: Optional[bool] = None secrets: Optional[ServiceConfigOrSecret] = None tags: Optional[List[str]] = None + platforms: Optional[List[str]] = None class BlkioConfig(YamlModel): @@ -394,6 +402,7 @@ class Secret(YamlModel): extra = Extra.forbid name: Optional[str] = None + environment: Optional[str] = None file: Optional[str] = None external: Optional[ExternalSecret] = None labels: Optional[ListOrDict] = None @@ -459,6 +468,7 @@ class Service(YamlModel): blkio_config: Optional[BlkioConfig] = None cap_add: Optional[List[str]] = Field(None, unique_items=True) cap_drop: Optional[List[str]] = Field(None, unique_items=True) + cgroup: Optional[Cgroup] = None cgroup_parent: Optional[str] = None command: Optional[Union[str, List[str]]] = None configs: Optional[ServiceConfigOrSecret] = None @@ -473,7 +483,9 @@ class Service(YamlModel): cpus: Optional[Union[float, str]] = None cpuset: Optional[str] = None credential_spec: Optional[CredentialSpec] = None - depends_on: Optional[Union[ListOfStrings, Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), DependsOn]]] = None # type: ignore # noqa: F722, E501 + depends_on: Optional[ + Union[ListOfStrings, Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), DependsOn]] # type: ignore # noqa: F722, E501 + ] = None device_cgroup_rules: Optional[ListOfStrings] = None devices: Optional[List[str]] = Field(None, unique_items=True) dns: Optional[StringOrList] = None @@ -503,10 +515,14 @@ class Service(YamlModel): mem_swappiness: Optional[int] = None memswap_limit: Optional[Union[float, str]] = None network_mode: Optional[str] = None - networks: Optional[Union[ListOfStrings, Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), Optional[ServiceNetwork]]]] = None # type: ignore # noqa: F722, E501 + networks: Optional[ + Union[ + ListOfStrings, Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), Optional[ServiceNetwork]] # type: ignore # noqa: F722, E501 + ] + ] = None oom_kill_disable: Optional[bool] = None oom_score_adj: Optional[conint(ge=-1000, le=1000)] = None # type: ignore - pid: Optional[Optional[str]] = None + pid: Optional[str] = None pids_limit: Optional[Union[float, str]] = None platform: Optional[str] = None ports: Optional[List[Union[float, str, Port]]] = Field(None, unique_items=True) @@ -529,6 +545,7 @@ class Service(YamlModel): tty: Optional[bool] = None ulimits: Optional[Dict[constr(regex=r"^[a-z]+$"), Union[int, Ulimit]]] = None # type: ignore # noqa: F722 user: Optional[str] = None + uts: Optional[str] = None userns_mode: Optional[str] = None volumes: Optional[List[Union[str, ServiceVolume]]] = Field(None, unique_items=True) volumes_from: Optional[List[str]] = Field(None, unique_items=True)