From a4b76bb8623c1fe449804643d0d06eb38068eee5 Mon Sep 17 00:00:00 2001 From: Vladislav Sukhin Date: Tue, 24 Dec 2024 18:53:24 +0300 Subject: [PATCH] fix: merge events Signed-off-by: Vladislav Sukhin --- pkg/event/kind/webhook/loader.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/event/kind/webhook/loader.go b/pkg/event/kind/webhook/loader.go index 1efc0f3d0d..c3d176342e 100644 --- a/pkg/event/kind/webhook/loader.go +++ b/pkg/event/kind/webhook/loader.go @@ -171,7 +171,21 @@ func mergeWebhooks(dst, src executorv1.Webhook) executorv1.Webhook { } } - // events + srcEventTypes := make(map[executorv1.EventType]struct{}) + for _, eventType := range src.Spec.Events { + srcEventTypes[eventType] = struct{}{} + } + + dstEventTypes := make(map[executorv1.EventType]struct{}) + for _, eventType := range dst.Spec.Events { + dstEventTypes[eventType] = struct{}{} + } + + for evenType := range srcEventTypes { + if _, ok := dstEventTypes[evenType]; !ok { + dst.Spec.Events = append(dst.Spec.Events, evenType) + } + } if !dst.Spec.Disabled && src.Spec.Disabled { dst.Spec.Disabled = src.Spec.Disabled