Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: set allValue to null when SVM regex is applied #2340

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading