mirror of
https://github.com/grafana/grafana.git
synced 2025-09-21 17:33:12 +08:00
Merge pull request #11379 from bergquist/provisioning_override_id
provisioning: removes id from dashboard.json
This commit is contained in:
@ -170,8 +170,8 @@ func (fr *fileReader) saveDashboard(path string, folderId int64, fileInfo os.Fil
|
|||||||
}
|
}
|
||||||
|
|
||||||
if dash.Dashboard.Id != 0 {
|
if dash.Dashboard.Id != 0 {
|
||||||
fr.log.Error("provisioned dashboard json files cannot contain id")
|
dash.Dashboard.Data.Set("id", nil)
|
||||||
return provisioningMetadata, nil
|
dash.Dashboard.Id = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if alreadyProvisioned {
|
if alreadyProvisioned {
|
||||||
|
@ -15,9 +15,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
defaultDashboards string = "./test-dashboards/folder-one"
|
defaultDashboards = "./test-dashboards/folder-one"
|
||||||
brokenDashboards string = "./test-dashboards/broken-dashboards"
|
brokenDashboards = "./test-dashboards/broken-dashboards"
|
||||||
oneDashboard string = "./test-dashboards/one-dashboard"
|
oneDashboard = "./test-dashboards/one-dashboard"
|
||||||
|
containingId = "./test-dashboards/containing-id"
|
||||||
|
|
||||||
fakeService *fakeDashboardProvisioningService
|
fakeService *fakeDashboardProvisioningService
|
||||||
)
|
)
|
||||||
@ -85,6 +86,18 @@ func TestDashboardFileReader(t *testing.T) {
|
|||||||
So(len(fakeService.inserted), ShouldEqual, 1)
|
So(len(fakeService.inserted), ShouldEqual, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Convey("Overrides id from dashboard.json files", func() {
|
||||||
|
cfg.Options["path"] = containingId
|
||||||
|
|
||||||
|
reader, err := NewDashboardFileReader(cfg, logger)
|
||||||
|
So(err, ShouldBeNil)
|
||||||
|
|
||||||
|
err = reader.startWalkingDisk()
|
||||||
|
So(err, ShouldBeNil)
|
||||||
|
|
||||||
|
So(len(fakeService.inserted), ShouldEqual, 1)
|
||||||
|
})
|
||||||
|
|
||||||
Convey("Invalid configuration should return error", func() {
|
Convey("Invalid configuration should return error", func() {
|
||||||
cfg := &DashboardsAsConfig{
|
cfg := &DashboardsAsConfig{
|
||||||
Name: "Default",
|
Name: "Default",
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
{
|
||||||
|
"title": "Grafana1",
|
||||||
|
"tags": [],
|
||||||
|
"id": 3,
|
||||||
|
"style": "dark",
|
||||||
|
"timezone": "browser",
|
||||||
|
"editable": true,
|
||||||
|
"rows": [
|
||||||
|
{
|
||||||
|
"title": "New row",
|
||||||
|
"height": "150px",
|
||||||
|
"collapse": false,
|
||||||
|
"editable": true,
|
||||||
|
"panels": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"span": 12,
|
||||||
|
"editable": true,
|
||||||
|
"type": "text",
|
||||||
|
"mode": "html",
|
||||||
|
"content": "<div class=\"text-center\" style=\"padding-top: 15px\">\n<img src=\"img/logo_transparent_200x.png\"> \n</div>",
|
||||||
|
"style": {},
|
||||||
|
"title": "Welcome to"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nav": [
|
||||||
|
{
|
||||||
|
"type": "timepicker",
|
||||||
|
"collapse": false,
|
||||||
|
"enable": true,
|
||||||
|
"status": "Stable",
|
||||||
|
"time_options": [
|
||||||
|
"5m",
|
||||||
|
"15m",
|
||||||
|
"1h",
|
||||||
|
"6h",
|
||||||
|
"12h",
|
||||||
|
"24h",
|
||||||
|
"2d",
|
||||||
|
"7d",
|
||||||
|
"30d"
|
||||||
|
],
|
||||||
|
"refresh_intervals": [
|
||||||
|
"5s",
|
||||||
|
"10s",
|
||||||
|
"30s",
|
||||||
|
"1m",
|
||||||
|
"5m",
|
||||||
|
"15m",
|
||||||
|
"30m",
|
||||||
|
"1h",
|
||||||
|
"2h",
|
||||||
|
"1d"
|
||||||
|
],
|
||||||
|
"now": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": {
|
||||||
|
"from": "now-6h",
|
||||||
|
"to": "now"
|
||||||
|
},
|
||||||
|
"templating": {
|
||||||
|
"list": []
|
||||||
|
},
|
||||||
|
"version": 5
|
||||||
|
}
|
Reference in New Issue
Block a user