diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9b26d29..e5b88bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: args: - "--max-line-length=120" - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort - repo: https://github.com/psf/black diff --git a/compose_viz/spec/compose-spec.json b/compose_viz/spec/compose-spec.json index 6f82797..c587125 100644 --- a/compose_viz/spec/compose-spec.json +++ b/compose_viz/spec/compose-spec.json @@ -13,6 +13,7 @@ "name": { "type": "string", + "pattern": "^[a-z0-9][a-z0-9_-]*$", "description": "define the Compose project name, until user defines one explicitly." }, @@ -90,12 +91,14 @@ "properties": { "context": {"type": "string"}, "dockerfile": {"type": "string"}, + "dockerfile_inline": {"type": "string"}, "args": {"$ref": "#/definitions/list_or_dict"}, "ssh": {"$ref": "#/definitions/list_or_dict"}, "labels": {"$ref": "#/definitions/list_or_dict"}, "cache_from": {"type": "array", "items": {"type": "string"}}, "cache_to": {"type": "array", "items": {"type": "string"}}, "no_cache": {"type": "boolean"}, + "additional_contexts": {"$ref": "#/definitions/list_or_dict"}, "network": {"type": "string"}, "pull": {"type": "boolean"}, "target": {"type": "string"}, @@ -143,12 +146,7 @@ "cap_drop": {"type": "array", "items": {"type": "string"}, "uniqueItems": true}, "cgroup": {"type": "string", "enum": ["host", "private"]}, "cgroup_parent": {"type": "string"}, - "command": { - "oneOf": [ - {"type": "string"}, - {"type": "array", "items": {"type": "string"}} - ] - }, + "command": {"$ref": "#/definitions/command"}, "configs": {"$ref": "#/definitions/service_config_or_secret"}, "container_name": {"type": "string"}, "cpu_count": {"type": "integer", "minimum": 0}, @@ -181,6 +179,7 @@ "type": "object", "additionalProperties": false, "properties": { + "restart": {"type": "boolean"}, "condition": { "type": "string", "enum": ["service_started", "service_healthy", "service_completed_successfully"] @@ -198,12 +197,7 @@ "dns_opt": {"type": "array","items": {"type": "string"}, "uniqueItems": true}, "dns_search": {"$ref": "#/definitions/string_or_list"}, "domainname": {"type": "string"}, - "entrypoint": { - "oneOf": [ - {"type": "string"}, - {"type": "array", "items": {"type": "string"}} - ] - }, + "entrypoint": {"$ref": "#/definitions/command"}, "env_file": {"$ref": "#/definitions/string_or_list"}, "environment": {"$ref": "#/definitions/list_or_dict"}, @@ -734,6 +728,14 @@ "patternProperties": {"^x-": {}} }, + "command": { + "oneOf": [ + {"type": "null"}, + {"type": "string"}, + {"type": "array","items": {"type": "string"}} + ] + }, + "string_or_list": { "oneOf": [ {"type": "string"}, diff --git a/compose_viz/spec/compose_spec.py b/compose_viz/spec/compose_spec.py index d1e466e..a02282a 100644 --- a/compose_viz/spec/compose_spec.py +++ b/compose_viz/spec/compose_spec.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: compose-spec.json -# timestamp: 2023-01-10T13:17:45+00:00 +# timestamp: 2023-05-03T07:42:00+00:00 from __future__ import annotations @@ -17,7 +17,7 @@ class Cgroup(YamlStrEnum): class CredentialSpec(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow config: Optional[str] = None file: Optional[str] = None @@ -32,14 +32,15 @@ class Condition(YamlStrEnum): class DependsOn(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow + restart: Optional[bool] = None condition: Condition class Extend(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow service: str file: Optional[str] = None @@ -47,7 +48,7 @@ class Extend(YamlModel): class Logging(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow driver: Optional[str] = None options: Optional[Dict[constr(regex=r"^.+$"), Optional[Union[str, float]]]] = None # type: ignore # noqa: F722 @@ -55,7 +56,7 @@ class Logging(YamlModel): class Port(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow mode: Optional[str] = None host_ip: Optional[str] = None @@ -74,7 +75,7 @@ class PullPolicy(YamlStrEnum): class Ulimit(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow hard: int soft: int @@ -87,7 +88,7 @@ class Selinux(YamlStrEnum): class Bind(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow propagation: Optional[str] = None create_host_path: Optional[bool] = None @@ -96,14 +97,14 @@ class Bind(YamlModel): class AdditionalVolumeOption(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow nocopy: Optional[bool] = None class Tmpfs(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow size: Optional[Union[conint(ge=0), str]] = None # type: ignore mode: Optional[float] = None @@ -111,7 +112,7 @@ class Tmpfs(YamlModel): class ServiceVolume(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow type: str source: Optional[str] = None @@ -125,7 +126,7 @@ class ServiceVolume(YamlModel): class Healthcheck(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow disable: Optional[bool] = None interval: Optional[str] = None @@ -142,7 +143,7 @@ class Order(YamlStrEnum): class RollbackConfig(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow parallelism: Optional[int] = None delay: Optional[str] = None @@ -159,7 +160,7 @@ class ConfigOrder(YamlStrEnum): class UpdateConfig(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow parallelism: Optional[int] = None delay: Optional[str] = None @@ -171,7 +172,7 @@ class UpdateConfig(YamlModel): class Limits(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow cpus: Optional[Union[float, str]] = None memory: Optional[str] = None @@ -180,7 +181,7 @@ class Limits(YamlModel): class RestartPolicy(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow condition: Optional[str] = None delay: Optional[str] = None @@ -190,14 +191,14 @@ class RestartPolicy(YamlModel): class Preference(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow spread: Optional[str] = None class Placement(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow constraints: Optional[List[str]] = None preferences: Optional[List[Preference]] = None @@ -206,7 +207,7 @@ class Placement(YamlModel): class DiscreteResourceSpec(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow kind: Optional[str] = None value: Optional[float] = None @@ -214,18 +215,21 @@ class DiscreteResourceSpec(YamlModel): class GenericResource(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow discrete_resource_spec: Optional[DiscreteResourceSpec] = None class GenericResources(YamlModel): + class Config: + extra = Extra.allow + __root__: List[GenericResource] class ConfigItem(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow subnet: Optional[str] = None ip_range: Optional[str] = None @@ -235,7 +239,7 @@ class ConfigItem(YamlModel): class Ipam(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow driver: Optional[str] = None config: Optional[List[ConfigItem]] = None @@ -244,14 +248,14 @@ class Ipam(YamlModel): class ExternalNetwork(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow name: Optional[str] = None class ExternalVolume(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow name: Optional[str] = None @@ -265,10 +269,16 @@ class ExternalConfig(YamlModel): class ListOfStrings(YamlModel): + class Config: + extra = Extra.allow + __root__: List[str] = Field(..., unique_items=True) class ListOrDict(YamlModel): + class Config: + extra = Extra.allow + __root__: Union[ Dict[constr(regex=r".+"), Optional[Union[str, float, bool]]], List[str] # type: ignore # noqa: F722 ] @@ -276,7 +286,7 @@ class ListOrDict(YamlModel): class BlkioLimit(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow path: Optional[str] = None rate: Optional[Union[int, str]] = None @@ -284,7 +294,7 @@ class BlkioLimit(YamlModel): class BlkioWeight(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow path: Optional[str] = None weight: Optional[int] = None @@ -292,7 +302,7 @@ class BlkioWeight(YamlModel): class ServiceConfigOrSecretItem(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow source: Optional[str] = None target: Optional[str] = None @@ -302,25 +312,33 @@ class ServiceConfigOrSecretItem(YamlModel): class ServiceConfigOrSecret(YamlModel): + class Config: + extra = Extra.allow + __root__: List[Union[str, ServiceConfigOrSecretItem]] class Constraints(YamlModel): + class Config: + extra = Extra.allow + __root__: Any class BuildItem(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow context: Optional[str] = None dockerfile: Optional[str] = None + dockerfile_inline: Optional[str] = None args: Optional[ListOrDict] = None ssh: Optional[ListOrDict] = None labels: Optional[ListOrDict] = None cache_from: Optional[List[str]] = None cache_to: Optional[List[str]] = None no_cache: Optional[bool] = None + additional_contexts: Optional[ListOrDict] = None network: Optional[str] = None pull: Optional[bool] = None target: Optional[str] = None @@ -335,7 +353,7 @@ class BuildItem(YamlModel): class BlkioConfig(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow device_read_bps: Optional[List[BlkioLimit]] = None device_read_iops: Optional[List[BlkioLimit]] = None @@ -347,7 +365,7 @@ class BlkioConfig(YamlModel): class ServiceNetwork(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow aliases: Optional[ListOfStrings] = None ipv4_address: Optional[str] = None @@ -358,7 +376,7 @@ class ServiceNetwork(YamlModel): class Device(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow capabilities: Optional[ListOfStrings] = None count: Optional[Union[str, int]] = None @@ -368,12 +386,15 @@ class Device(YamlModel): class Devices(YamlModel): + class Config: + extra = Extra.allow + __root__: List[Device] class Network(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow name: Optional[str] = None driver: Optional[str] = None @@ -388,7 +409,7 @@ class Network(YamlModel): class Volume(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow name: Optional[str] = None driver: Optional[str] = None @@ -399,7 +420,7 @@ class Volume(YamlModel): class Secret(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow name: Optional[str] = None environment: Optional[str] = None @@ -413,7 +434,7 @@ class Secret(YamlModel): class Config(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow name: Optional[str] = None file: Optional[str] = None @@ -423,12 +444,15 @@ class Config(YamlModel): class StringOrList(YamlModel): + class Config: + extra = Extra.allow + __root__: Union[str, ListOfStrings] class Reservations(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow cpus: Optional[Union[float, str]] = None memory: Optional[str] = None @@ -438,7 +462,7 @@ class Reservations(YamlModel): class Resources(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow limits: Optional[Limits] = None reservations: Optional[Reservations] = None @@ -446,7 +470,7 @@ class Resources(YamlModel): class Deployment(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow mode: Optional[str] = None endpoint_mode: Optional[str] = None @@ -461,7 +485,7 @@ class Deployment(YamlModel): class Service(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow deploy: Optional[Deployment] = None build: Optional[Union[str, BuildItem]] = None @@ -554,10 +578,10 @@ class Service(YamlModel): class ComposeSpecification(YamlModel): class Config: - extra = Extra.forbid + extra = Extra.allow version: Optional[str] = Field(None, description="declared for backward compatibility, ignored.") - name: Optional[str] = Field( + name: Optional[constr(regex=r"^[a-z0-9][a-z0-9_-]*$")] = Field( # type: ignore # noqa: F722 None, description="define the Compose project name, until user defines one explicitly.", )