Skip to content

Commit

Permalink
Actually enforce dashboard schema on devenv (grafana#53797)
Browse files Browse the repository at this point in the history
* Relocate dashboards test so it runs

* Cover newer schema versions in stripnulls

* Strip nulls and remove iteration fields

* Fix fiscalYearStartMonth bounds

* Fix up and format dashboard schema

* Update thema, tidy Go dependencies
  • Loading branch information
sam boyer authored Aug 17, 2022
1 parent 25de383 commit c23a9d7
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 95,
"iteration": 1652465568602,
"links": [],
"liveNow": false,
"panels": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 85,
"iteration": 1652465607869,
"links": [],
"liveNow": false,
"panels": [
Expand Down
11 changes: 4 additions & 7 deletions devenv/dev-dashboards/panel-geomap/geomap-9.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
"color": "green"
},
{
"color": "red",
Expand Down Expand Up @@ -151,8 +150,7 @@
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
"color": "green"
},
{
"color": "red",
Expand Down Expand Up @@ -238,8 +236,7 @@
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
"color": "green"
},
{
"color": "red",
Expand Down Expand Up @@ -360,4 +357,4 @@
"uid": "KVxZKdmVz",
"version": 10,
"weekStart": ""
}
}
14 changes: 5 additions & 9 deletions devenv/dev-dashboards/panel-geomap/panel-geomap.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
"color": "green"
},
{
"color": "red",
Expand Down Expand Up @@ -152,8 +151,7 @@
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
"color": "green"
},
{
"color": "red",
Expand Down Expand Up @@ -259,8 +257,7 @@
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
"color": "green"
},
{
"color": "red",
Expand Down Expand Up @@ -358,8 +355,7 @@
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
"color": "green"
},
{
"color": "red",
Expand Down Expand Up @@ -474,4 +470,4 @@
"uid": "2xuwrgV7z",
"version": 4,
"weekStart": ""
}
}
5 changes: 2 additions & 3 deletions devenv/dev-dashboards/panel-graph/graph-ng-stacking2.json
Original file line number Diff line number Diff line change
Expand Up @@ -3414,8 +3414,7 @@
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
"color": "green"
},
{
"color": "red",
Expand Down Expand Up @@ -3489,4 +3488,4 @@
"uid": "1KxMUdE7k",
"version": 5,
"weekStart": ""
}
}
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ require (
go.opentelemetry.io/otel/trace v1.6.3
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d
golang.org/x/exp v0.0.0-20220613132600-b0d781184e0d
golang.org/x/net v0.0.0-20220615171555-694bf12d69de // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
golang.org/x/time v0.0.0-20220609170525-579cf78fd858
golang.org/x/tools v0.1.11
golang.org/x/tools v0.1.12
gonum.org/v1/gonum v0.11.0
google.golang.org/api v0.74.0
google.golang.org/grpc v1.45.0
Expand Down Expand Up @@ -227,7 +227,7 @@ require (
go.opencensus.io v0.23.0 // indirect
go.uber.org/atomic v1.9.0
go.uber.org/goleak v1.1.12 // indirect
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
golang.org/x/text v0.3.7
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand All @@ -247,7 +247,7 @@ require (
github.com/golang-migrate/migrate/v4 v4.7.0
github.com/google/go-github/v45 v45.2.0
github.com/grafana/dskit v0.0.0-20211011144203-3a88ec0b675f
github.com/grafana/thema v0.0.0-20220726124731-b8017e278cc1
github.com/grafana/thema v0.0.0-20220816214754-af057f99a2dd
github.com/jmoiron/sqlx v1.3.5
go.etcd.io/etcd/api/v3 v3.5.4
go.opentelemetry.io/contrib/propagators/jaeger v1.6.0
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1356,8 +1356,8 @@ github.com/grafana/grafana-plugin-sdk-go v0.139.0 h1:2RQKM2QpSaWTtaGN6sK+R7LO7zy
github.com/grafana/grafana-plugin-sdk-go v0.139.0/go.mod h1:Y+Ps2sesZ62AyCnX+hzrYnyDQYe/ZZl+A8yKLOBm12c=
github.com/grafana/saml v0.4.9-0.20220727151557-61cd9c9353fc h1:1PY8n+rXuBNr3r1JQhoytWDCpc+pq+BibxV0SZv+Cr4=
github.com/grafana/saml v0.4.9-0.20220727151557-61cd9c9353fc/go.mod h1:9Zh6dWPtB3MSzTRt8fIFH60Z351QQ+s7hCU3J/tTlA4=
github.com/grafana/thema v0.0.0-20220726124731-b8017e278cc1 h1:BENUTE1rqYy6gcRdIAbiuSROpAYwmg3aW4CWGqoSIk4=
github.com/grafana/thema v0.0.0-20220726124731-b8017e278cc1/go.mod h1:fCV1rqv6XRQg2GfIQ7pU9zdxd5fLRcEBCnrDVwlK+ZY=
github.com/grafana/thema v0.0.0-20220816214754-af057f99a2dd h1:OukQ1Nu4PSreZTAaOfXyYhM9jYBs4UflVfOSAIG8JzM=
github.com/grafana/thema v0.0.0-20220816214754-af057f99a2dd/go.mod h1:fCV1rqv6XRQg2GfIQ7pU9zdxd5fLRcEBCnrDVwlK+ZY=
github.com/grafana/xorm v0.8.3-0.20220614223926-2fcda7565af6 h1:I9dh1MXGX0wGyxdV/Sl7+ugnki4Dfsy8lv2s5Yf887o=
github.com/grafana/xorm v0.8.3-0.20220614223926-2fcda7565af6/go.mod h1:ZkJLEYLoVyg7amJK/5r779bHyzs2AU8f8VMiP6BM7uY=
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
Expand Down Expand Up @@ -2842,8 +2842,8 @@ golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su
golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220401154927-543a649e0bdd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220418201149-a630d4f3e7a2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220615171555-694bf12d69de h1:ogOG2+P6LjO2j55AkRScrkB2BFpd+Z8TY2wcM0Z3MGo=
golang.org/x/net v0.0.0-20220615171555-694bf12d69de/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -2884,8 +2884,8 @@ golang.org/x/sync v0.0.0-20200930132711-30421366ff76/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f h1:Ax0t5p6N38Ga0dThY21weqDEyz2oklo4IvDkpigvkD8=
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -3054,8 +3054,8 @@ golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c h1:aFV+BgZ4svzjfabn8ERpuB4JI4N6/rdy1iusx77G3oU=
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand Down Expand Up @@ -3196,8 +3196,8 @@ golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/tools v0.1.11 h1:loJ25fNOEhSXfHrpoGj91eCUThwdNX6u24rO1xnNteY=
golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ interface Dashboard {
enable: boolean;
hidden: boolean;
refresh_intervals: string[];
time_options: string[];
};
timezone?: ('browser' | 'utc' | '');
title?: string;
Expand Down
76 changes: 41 additions & 35 deletions pkg/coremodel/dashboard/coremodel.cue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ seqs: [
// Timezone of dashboard,
timezone?: *"browser" | "utc" | "" @reviewme()
// Whether a dashboard is editable or not.
editable: bool | *true
editable: bool | *true
graphTooltip: #DashboardCursorSync @reviewme()
// Time range for dashboard, e.g. last 6 hours, last 7 days, etc
time?: {
Expand All @@ -49,9 +49,11 @@ seqs: [
hidden: bool | *false
// Selectable intervals for auto-refresh.
refresh_intervals: [...string] | *["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"]
// TODO docs
time_options: [...string] | *["5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d", "30d"]
} @reviewme()
// TODO docs
fiscalYearStartMonth?: uint8 & >0 & <13 @reviewme()
fiscalYearStartMonth?: uint8 & <13 @reviewme()
// TODO docs
liveNow?: bool @reviewme()
// TODO docs
Expand All @@ -67,9 +69,13 @@ seqs: [
version?: uint32 @reviewme()
panels?: [...(#Panel | #RowPanel | #GraphPanel | #HeatmapPanel)] @reviewme()
// TODO docs
templating?: list: [...#VariableModel] @reviewme()
templating?: {
list: [...#VariableModel] @reviewme()
}
// TODO docs
annotations?: list: [...#AnnotationQuery] @reviewme()
annotations?: {
list: [...#AnnotationQuery] @reviewme()
}
// TODO docs
links?: [...#DashboardLink] @reviewme()

Expand All @@ -88,43 +94,43 @@ seqs: [
// Whether annotation is enabled.
enable: bool | *true @reviewme()
// Name of annotation.
name?: string @reviewme()
name?: string @reviewme()
builtIn: uint8 | *0 @reviewme() // TODO should this be persisted at all?
// Whether to hide annotation.
hide?: bool | *false @reviewme()
// Annotation icon color.
iconColor?: string @reviewme()
type: string | *"dashboard" @reviewme()
iconColor?: string @reviewme()
type: string | *"dashboard" @reviewme()
// Query for annotation data.
rawQuery?: string @reviewme()
rawQuery?: string @reviewme()
showIn: uint8 | *0 @reviewme()
target?: #Target @reviewme() // TODO currently a generic in AnnotationQuery
target?: #Target @reviewme() // TODO currently a generic in AnnotationQuery
} @cuetsy(kind="interface")

// FROM: packages/grafana-data/src/types/templateVars.ts
// TODO docs
// TODO what about what's in public/app/features/types.ts?
// TODO there appear to be a lot of different kinds of [template] vars here? if so need a disjunction
#VariableModel: {
type: #VariableType
name: string
type: #VariableType
name: string
label?: string
...
} @cuetsy(kind="interface") @reviewme()

// FROM public/app/features/dashboard/state/DashboardModels.ts - ish
// TODO docs
#DashboardLink: {
title: string @reviewme()
type: #DashboardLinkType @reviewme()
icon?: string @reviewme()
tooltip?: string @reviewme()
url?: string @reviewme()
title: string @reviewme()
type: #DashboardLinkType @reviewme()
icon?: string @reviewme()
tooltip?: string @reviewme()
url?: string @reviewme()
tags: [...string] @reviewme()
asDropdown: bool | *false @reviewme()
asDropdown: bool | *false @reviewme()
targetBlank: bool | *false @reviewme()
includeVars: bool | *false @reviewme()
keepTime: bool | *false @reviewme()
keepTime: bool | *false @reviewme()
} @cuetsy(kind="interface")

// TODO docs
Expand All @@ -151,18 +157,18 @@ seqs: [
seriesBy?: #FieldColorSeriesByMode
} @cuetsy(kind="interface") @reviewme()

#GridPos: {
// Panel
h: uint32 & >0 | *9 @reviewme()
// Panel
w: uint32 & >0 & <=24 | *12 @reviewme()
// Panel x
x: uint32 & >=0 & <24 | *0 @reviewme()
// Panel y
y: uint32 & >=0 | *0 @reviewme()
// true if fixed
static?: bool @reviewme()
} @cuetsy(kind="interface")
#GridPos: {
// Panel
h: uint32 & >0 | *9 @reviewme()
// Panel
w: uint32 & >0 & <=24 | *12 @reviewme()
// Panel x
x: uint32 & >=0 & <24 | *0 @reviewme()
// Panel y
y: uint32 & >=0 | *0 @reviewme()
// true if fixed
static?: bool @reviewme()
} @cuetsy(kind="interface")

// TODO docs
#Threshold: {
Expand Down Expand Up @@ -343,21 +349,21 @@ seqs: [
overrides: [...{
matcher: {
id: string | *"" @reviewme()
options?: _ @reviewme()
options?: _ @reviewme()
}
properties: [...{
id: string | *"" @reviewme()
value?: _ @reviewme()
value?: _ @reviewme()
}]
}] @reviewme()
}
} @cuetsy(kind="interface") @reviewme()

// Row panel
#RowPanel: {
type: "row" @reviewme()
type: "row" @reviewme()
collapsed: bool | *false @reviewme()
title?: string @reviewme()
title?: string @reviewme()

// Name of default datasource.
datasource?: {
Expand All @@ -366,7 +372,7 @@ seqs: [
} @reviewme()

gridPos?: #GridPos
id: uint32 @reviewme()
id: uint32 @reviewme()
panels: [...(#Panel | #GraphPanel | #HeatmapPanel)] @reviewme()
// Name of template variable to repeat for.
repeat?: string @reviewme()
Expand Down
Loading

0 comments on commit c23a9d7

Please sign in to comment.