Skip to content

Commit

Permalink
feat: All Harvest dashboards should include tags
Browse files Browse the repository at this point in the history
  • Loading branch information
cgrinds committed Oct 8, 2024
1 parent dea5ddb commit 7cc5481
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
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

0 comments on commit 7cc5481

Please sign in to comment.