Skip to content

Commit

Permalink
feat: set allValue to null when SVM regex is applied
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulguptajss committed Sep 4, 2023
1 parent f81e16f commit 0afa49a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions cmd/tools/grafana/grafana.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,25 +185,27 @@ func exportFiles(dir string, folder *Folder) error {
}

func addSvmRegex(content []byte, fileName string, val string) []byte {
var err error
newContent := content
var svmExpression []string
svmExpression := []string{"templating.list.#(name=\"SVM\")"}
if fileName == "snapmirror.json" {
svmExpression = []string{"templating.list.#(name=\"DestinationSVM\")", "templating.list.#(name=\"SourceSVM\")"}
} else {
svmExpression = []string{"templating.list.#(name=\"SVM\")"}
}
for _, s := range svmExpression {
var err error
svm := gjson.GetBytes(content, s)
if svm.Exists() {
newContent, err = sjson.SetBytes(newContent, s+".regex", []byte(val))
content, err = sjson.SetBytes(content, s+".regex", []byte(val))
if err != nil {
fmt.Printf("Error while setting svm regex: %v\n", err)
continue
}
content, err = sjson.SetBytes(content, s+".allValue", json.RawMessage("null"))
if err != nil {
fmt.Printf("error while setting svm regex")
fmt.Printf("Error while setting svm allValue: %v\n", err)
continue
}
}
}
return newContent
return content
}

func addLabel(content []byte, label string, labelMap map[string]string) []byte {
Expand Down

0 comments on commit 0afa49a

Please sign in to comment.