From 46be579991ed79c7cabab0f69fc6fedc0c6eaba4 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 8 Jan 2024 13:32:53 +0100 Subject: [PATCH] cli/compose: allow depends_on advanced syntax While stack does not support "depends_on", and will produce an warning when used, it's useful to allow it to _parse_ a compose-file that uses the advanced syntax. Signed-off-by: Sebastiaan van Stijn --- cli/compose/loader/full-example.yml | 6 ++++ .../loader/testdata/full-example.yaml.golden | 6 ++++ .../schema/data/config_schema_v3.12.json | 28 ++++++++++++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/cli/compose/loader/full-example.yml b/cli/compose/loader/full-example.yml index 76447d203a..5e7bbcd0e9 100644 --- a/cli/compose/loader/full-example.yml +++ b/cli/compose/loader/full-example.yml @@ -1,6 +1,12 @@ version: "3.12" services: + bar: + image: busybox:latest + depends_on: + foo: + condition: service_started + required: true foo: build: diff --git a/cli/compose/loader/testdata/full-example.yaml.golden b/cli/compose/loader/testdata/full-example.yaml.golden index 83e2b8342f..3c08dea391 100644 --- a/cli/compose/loader/testdata/full-example.yaml.golden +++ b/cli/compose/loader/testdata/full-example.yaml.golden @@ -1,5 +1,11 @@ version: "3.12" services: + bar: + image: busybox:latest + depends_on: + foo: + condition: service_started + required: true foo: build: context: ./dir diff --git a/cli/compose/schema/data/config_schema_v3.12.json b/cli/compose/schema/data/config_schema_v3.12.json index 2a548a3816..cc49b33fbe 100644 --- a/cli/compose/schema/data/config_schema_v3.12.json +++ b/cli/compose/schema/data/config_schema_v3.12.json @@ -133,7 +133,33 @@ }, "additionalProperties": false }, - "depends_on": {"$ref": "#/definitions/list_of_strings"}, + "depends_on": { + "oneOf": [ + {"$ref": "#/definitions/list_of_strings"}, + { + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^[a-zA-Z0-9._-]+$": { + "type": "object", + "additionalProperties": false, + "properties": { + "restart": {"type": "boolean"}, + "required": { + "type": "boolean", + "default": true + }, + "condition": { + "type": "string", + "enum": ["service_started", "service_healthy", "service_completed_successfully"] + } + }, + "required": ["condition"] + } + } + } + ] + }, "devices": {"type": "array", "items": {"type": "string"}, "uniqueItems": true}, "dns": {"$ref": "#/definitions/string_or_list"}, "dns_search": {"$ref": "#/definitions/string_or_list"},