Strip id/uid from .json input
As noted inline, a default export from Grafana includes the uid/id which breaks when you re-import it into a different site. Strip them. Change-Id: I318614b33aed2ece93d44e832bad7907724cb1bc
This commit is contained in:
parent
2c3823432d
commit
72080f7136
@ -56,6 +56,13 @@ class YamlParser(object):
|
|||||||
slug = slugify(data['title'])
|
slug = slugify(data['title'])
|
||||||
if not self.data.get('dashboard'):
|
if not self.data.get('dashboard'):
|
||||||
self.data['dashboard'] = {}
|
self.data['dashboard'] = {}
|
||||||
|
# The idea is that people work interactively locally using
|
||||||
|
# the GUI editor, then export the .json using the sharing
|
||||||
|
# panel. That mostly works, but it can leave a id & uid
|
||||||
|
# that isn't valid when importing to another grafana
|
||||||
|
# instance. Remove them.
|
||||||
|
data.pop('id', None)
|
||||||
|
data.pop('uid', None)
|
||||||
self.data['dashboard'][slug] = data
|
self.data['dashboard'][slug] = data
|
||||||
else:
|
else:
|
||||||
result = self.validate(data)
|
result = self.validate(data)
|
||||||
|
@ -137,5 +137,6 @@
|
|||||||
"timezone": "",
|
"timezone": "",
|
||||||
"title": "test json",
|
"title": "test json",
|
||||||
"uid": "M-GEcyWMk",
|
"uid": "M-GEcyWMk",
|
||||||
"version": 1
|
"version": 1,
|
||||||
|
"id": 1234
|
||||||
}
|
}
|
||||||
|
@ -109,3 +109,5 @@ class TestCaseParser(TestCase):
|
|||||||
# Get parsed dashboard
|
# Get parsed dashboard
|
||||||
res, md5 = self.parser.get_dashboard('test-json')
|
res, md5 = self.parser.get_dashboard('test-json')
|
||||||
self.assertEqual(res['title'], 'test json')
|
self.assertEqual(res['title'], 'test json')
|
||||||
|
self.assertNotIn('id', res.keys())
|
||||||
|
self.assertNotIn('uid', res.keys())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user