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'])
|
||||
if not self.data.get('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
|
||||
else:
|
||||
result = self.validate(data)
|
||||
|
@ -137,5 +137,6 @@
|
||||
"timezone": "",
|
||||
"title": "test json",
|
||||
"uid": "M-GEcyWMk",
|
||||
"version": 1
|
||||
"version": 1,
|
||||
"id": 1234
|
||||
}
|
||||
|
@ -109,3 +109,5 @@ class TestCaseParser(TestCase):
|
||||
# Get parsed dashboard
|
||||
res, md5 = self.parser.get_dashboard('test-json')
|
||||
self.assertEqual(res['title'], 'test json')
|
||||
self.assertNotIn('id', res.keys())
|
||||
self.assertNotIn('uid', res.keys())
|
||||
|
Loading…
Reference in New Issue
Block a user