From d9f54bf9495e5a142b2cfcc30fbb53bc783c6cd3 Mon Sep 17 00:00:00 2001 From: Emma Karova <56153974+emmakarova@users.noreply.github.com> Date: Wed, 15 May 2024 14:41:29 +0300 Subject: [PATCH] [HOTFIX] Fix processing of jsonpath for SLIS select criteria (#3875) * Fix processing of jsonpath for slis select criteria * Fix lint --- components/director/cmd/systemfetcher/main.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/components/director/cmd/systemfetcher/main.go b/components/director/cmd/systemfetcher/main.go index 289fb39868..193da91080 100644 --- a/components/director/cmd/systemfetcher/main.go +++ b/components/director/cmd/systemfetcher/main.go @@ -6,6 +6,7 @@ import ( "encoding/json" "net/http" "os" + "regexp" "strings" "sync" "time" @@ -704,15 +705,15 @@ func calculateTemplateMappings(ctx context.Context, cfg config, transact persist } func getTopParentFromJSONPath(jsonPath string) string { - infix := "." + trimmedJSONPath := strings.TrimPrefix(jsonPath, systemfetcher.TrimPrefix) - topParent := strings.TrimPrefix(jsonPath, systemfetcher.TrimPrefix) - firstInfixIndex := strings.Index(topParent, infix) - if firstInfixIndex == -1 { - return topParent + regexForTopParent := regexp.MustCompile(`^[^\[.]+`) + topParent := regexForTopParent.FindStringSubmatch(trimmedJSONPath) + if len(topParent) > 0 { + return topParent[0] } - return topParent[:firstInfixIndex] + return trimmedJSONPath } func addPropertiesFromAppTemplatePlaceholders(selectFilterProperties map[string]bool, placeholders []model.ApplicationTemplatePlaceholder) {