From cc3d6c2d3bf2504f3cf2fcbd9088ee7b1f8c4e89 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Wed, 11 Dec 2024 14:44:47 +0100 Subject: [PATCH 1/2] [core] Add json.Sort function to workflow template context --- configuration/template/stack.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/configuration/template/stack.go b/configuration/template/stack.go index fbbf3a02..2ba94b6e 100644 --- a/configuration/template/stack.go +++ b/configuration/template/stack.go @@ -263,6 +263,20 @@ func MakeUtilFuncMap(varStack map[string]string) map[string]interface{} { out = string(bytes) return }, + "Sort": func(in interface{}) (out interface{}) { + switch inSlice := in.(type) { + case []interface{}: + stringSlice := make([]string, len(inSlice)) + for idx, item := range inSlice { + stringSlice[idx] = fmt.Sprintf("%v", item) + } + slices.Sort(stringSlice) + out = stringSlice + default: + out = in + } + return + }, } jsonMap["Deserialize"] = jsonMap["Unmarshal"] jsonMap["Serialize"] = jsonMap["Marshal"] From 096d579ffae3ca1df288fd2aeaf4b3aead1ca081 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Wed, 11 Dec 2024 14:45:13 +0100 Subject: [PATCH 2/2] [core] Sort detector list before including in ODC payload --- core/integration/odc/plugin.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/integration/odc/plugin.go b/core/integration/odc/plugin.go index a881f4b3..ea3a7a28 100644 --- a/core/integration/odc/plugin.go +++ b/core/integration/odc/plugin.go @@ -33,6 +33,7 @@ import ( "encoding/json" "fmt" "net/url" + "slices" "strconv" "strings" "sync" @@ -715,6 +716,7 @@ func (p *Plugin) ObjectStack(varStack map[string]string, baseConfigStack map[str if ok && strings.ToLower(strings.TrimSpace(ctpReadoutEnabled)) == "true" { detectorsSlice = append(detectorsSlice, "TRG") } + slices.Sort(detectorsSlice) pdpDetectorList = strings.Join(detectorsSlice, ",") } accumulator = append(accumulator, fmt.Sprintf("WORKFLOW_DETECTORS='%s'", strings.TrimSpace(pdpDetectorList))) @@ -1231,6 +1233,7 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) { if ok { detectorsSlice, err := p.parseDetectors(detectorListS) if err == nil { + slices.Sort(detectorsSlice) arguments["detectors"] = strings.Join(detectorsSlice, ",") } else { log.WithField("partition", envId).