From bdca875ba290b1d0901d4dc3ea8412d0f919bca8 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Wed, 27 Nov 2024 09:46:07 +0100 Subject: [PATCH] introduce sync+exec watch action Signed-off-by: Nicolas De Loof --- schema/compose-spec.json | 5 +++-- types/derived.gen.go | 5 +++++ types/develop.go | 2 ++ types/mapping.go | 10 ++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/schema/compose-spec.json b/schema/compose-spec.json index a34a0dc3..fc50f193 100644 --- a/schema/compose-spec.json +++ b/schema/compose-spec.json @@ -500,8 +500,9 @@ "properties": { "ignore": {"type": "array", "items": {"type": "string"}}, "path": {"type": "string"}, - "action": {"type": "string", "enum": ["rebuild", "sync", "sync+restart"]}, - "target": {"type": "string"} + "action": {"type": "string", "enum": ["rebuild", "sync", "sync+restart", "sync+exec"]}, + "target": {"type": "string"}, + "exec": {"$ref": "#/definitions/service_hook"} }, "additionalProperties": false, "patternProperties": {"^x-": {}} diff --git a/types/derived.gen.go b/types/derived.gen.go index 295a8514..f4f2db56 100644 --- a/types/derived.gen.go +++ b/types/derived.gen.go @@ -2013,6 +2013,11 @@ func deriveDeepCopy_46(dst, src *Trigger) { dst.Path = src.Path dst.Action = src.Action dst.Target = src.Target + func() { + field := new(ServiceHook) + deriveDeepCopy_44(field, &src.Exec) + dst.Exec = *field + }() if src.Ignore == nil { dst.Ignore = nil } else { diff --git a/types/develop.go b/types/develop.go index 24e142c3..b904d685 100644 --- a/types/develop.go +++ b/types/develop.go @@ -28,12 +28,14 @@ const ( WatchActionSync WatchAction = "sync" WatchActionRebuild WatchAction = "rebuild" WatchActionSyncRestart WatchAction = "sync+restart" + WatchActionSyncExec WatchAction = "sync+exec" ) type Trigger struct { Path string `yaml:"path" json:"path"` Action WatchAction `yaml:"action" json:"action"` Target string `yaml:"target,omitempty" json:"target,omitempty"` + Exec ServiceHook `yaml:"exec,omitempty" json:"exec,omitempty"` Ignore []string `yaml:"ignore,omitempty" json:"ignore,omitempty"` Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"` } diff --git a/types/mapping.go b/types/mapping.go index de6fb123..63f6e58b 100644 --- a/types/mapping.go +++ b/types/mapping.go @@ -72,6 +72,16 @@ func (m MappingWithEquals) RemoveEmpty() MappingWithEquals { return m } +func (m MappingWithEquals) ToMapping() Mapping { + o := Mapping{} + for k, v := range m { + if v != nil { + o[k] = *v + } + } + return o +} + func (m *MappingWithEquals) DecodeMapstructure(value interface{}) error { switch v := value.(type) { case map[string]interface{}: