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: All Harvest dashboards should include tags #3202

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
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
32 changes: 32 additions & 0 deletions cmd/tools/grafana/dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package grafana
import (
"fmt"
"github.com/tidwall/gjson"
"maps"
"net/url"
"os"
"path/filepath"
Expand Down Expand Up @@ -1779,3 +1780,34 @@ func checkPanelLinks(t *testing.T, value gjson.Result, path string, hasLinks map
})
}
}

func TestTags(t *testing.T) {
VisitDashboards(dashboards,
func(path string, data []byte) {
checkTags(t, path, data)
})
}

func checkTags(t *testing.T, path string, data []byte) {
allowedTagsMap := map[string]bool{
"cdot": true,
"fsx": true,
"harvest": true,
"ontap": true,
"storagegrid": true,
}

path = ShortPath(path)
tags := gjson.GetBytes(data, "tags").Array()
if len(tags) == 0 {
t.Errorf(`dashboard=%s got tags are empty, but should have tags`, path)
return
}

for _, tag := range tags {
if !allowedTagsMap[tag.String()] {
allowedTags := slices.Sorted(maps.Keys(allowedTagsMap))
t.Errorf(`dashboard=%s got tag=%s, which is not in the allowed set=%v`, path, tag.String(), allowedTags)
}
}
}
4 changes: 3 additions & 1 deletion grafana/dashboards/cmode/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3144,7 +3144,9 @@
"refresh": "",
"schemaVersion": 30,
"style": "dark",
"tags": [],
"tags": [
"harvest"
],
"templating": {
"list": [
{
Expand Down
6 changes: 5 additions & 1 deletion grafana/dashboards/cmode/vscan.json
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,11 @@
"refresh": "",
"schemaVersion": 30,
"style": "dark",
"tags": [],
"tags": [
"cdot",
"harvest",
"ontap"
],
"templating": {
"list": [
{
Expand Down