From 3633a8da30e7d114fb5fffea8a972c0aefd03f54 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Wed, 18 Dec 2024 17:22:16 +0100 Subject: [PATCH] introduce depends_on.service Signed-off-by: Nicolas De Loof --- schema/compose-spec.json | 1 + transform/dependson.go | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/schema/compose-spec.json b/schema/compose-spec.json index f95a7b9d..583e4015 100644 --- a/schema/compose-spec.json +++ b/schema/compose-spec.json @@ -198,6 +198,7 @@ "additionalProperties": false, "patternProperties": {"^x-": {}}, "properties": { + "service": {"type": "string"}, "restart": {"type": ["boolean", "string"]}, "required": { "type": "boolean", diff --git a/transform/dependson.go b/transform/dependson.go index 0a72ffa4..d83b2dd5 100644 --- a/transform/dependson.go +++ b/transform/dependson.go @@ -25,10 +25,10 @@ import ( func transformDependsOn(data any, p tree.Path, _ bool) (any, error) { switch v := data.(type) { case map[string]any: - for i, e := range v { + for k, e := range v { d, ok := e.(map[string]any) if !ok { - return nil, fmt.Errorf("%s.%s: unsupported value %s", p, i, v) + return nil, fmt.Errorf("%s.%s: unsupported value %s", p, k, v) } if _, ok := d["condition"]; !ok { d["condition"] = "service_started" @@ -36,6 +36,9 @@ func transformDependsOn(data any, p tree.Path, _ bool) (any, error) { if _, ok := d["required"]; !ok { d["required"] = true } + if _, ok := d["service"]; !ok { + d["service"] = k + } } return v, nil case []any: