refactory to move trim/apply default into schema.go (#33754)

* refactory to move trim/apply default into schema.go

* fix comments

* move schema test outside of load folder
This commit is contained in:
ying-jeanne
2021-05-12 15:38:00 +08:00
committed by GitHub
parent 679001051b
commit a7ea0ca849
12 changed files with 250 additions and 285 deletions
@@ -1,35 +0,0 @@
Verifies common usecases for trimdefault/applydefault functions:
* Basic cases
* Real dashboard
-- CUE --
{
id?: number
uid: string
gnetId?: string
style: *"light" | "dark"
timezone?: *"browser" | "utc"
editable: bool | *true
schemaVersion: number | *25
version?: number
graphTooltip: >=0 & <=2 | *0
}
-- Full --
{
"id": 42,
"uid": "emal8gQMz",
"style": "light",
"editable": true,
"schemaVersion": 27,
"version": 2,
"graphTooltip": 0
}
-- Trimed --
{
"id": 42,
"uid": "emal8gQMz",
"schemaVersion": 27,
"version": 2
}
@@ -1,41 +0,0 @@
Verifies common usecases for trimdefault/applydefault functions:
* Basic cases
* Real dashboard
-- CUE --
{
timepicker?: {
collapse: bool | *false
enable: bool | *true
hidden: bool | *false
refresh_intervals: [...string] | *["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"]
}
}
-- Full --
{
"timepicker": {
"collapse": true,
"enable":true,
"hidden":false,
"refresh_intervals":[
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
]
}
}
-- Trimed --
{
"timepicker": {
"collapse": true
}
}
@@ -1,46 +0,0 @@
Verifies common usecases for trimdefault/applydefault functions:
* Nested struct
* Simple array
-- CUE --
{
annotations?: list: [...{
builtIn: number | *0
datasource: string
enable?: bool | *true
hide?: bool | *false
iconColor?: string
name?: string
type: string | *"dashboard"
rawQuery?: string
showIn: number | *0
}]
}
-- Full --
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"name": "Annotations & Alerts",
"type": "dashboard",
"showIn": 0
}
]
}
}
-- Trimed --
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"name": "Annotations & Alerts"
}
]
}
}
@@ -1,73 +0,0 @@
Verifies common usecases for trimdefault/applydefault functions:
* open structure should be kept when fields not present
-- CUE --
{
templating?: list: [...{...}]
}
-- Full --
{
"templating": {
"list": [
{
"allValue": null,
"current": {
"text": "America",
"value": "America"
},
"datasource": "gdev-postgres",
"definition": "",
"hide": 0,
"includeAll": false,
"label": "Datacenter",
"multi": false,
"name": "datacenter",
"options": [],
"query": "SELECT DISTINCT datacenter FROM grafana_metric",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 1,
"tagValuesQuery": "",
"tags": [],
"tagsQuery": "",
"type": "query",
"useTags": false
}
]
}
}
-- Trimed --
{
"templating": {
"list": [
{
"allValue": null,
"current": {
"text": "America",
"value": "America"
},
"datasource": "gdev-postgres",
"definition": "",
"hide": 0,
"includeAll": false,
"label": "Datacenter",
"multi": false,
"name": "datacenter",
"options": [],
"query": "SELECT DISTINCT datacenter FROM grafana_metric",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 1,
"tagValuesQuery": "",
"tags": [],
"tagsQuery": "",
"type": "query",
"useTags": false
}
]
}
}