Skip to content

Commit 1f26aa5

Browse files
committed
add .yaml and wrap when adding to configmap
1 parent 09fc210 commit 1f26aa5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

prometheus-ksonnet/grafana/datasources.libsonnet

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@
3434
*/
3535
grafana_add_datasource(name, url, default=false, method='GET')::
3636
configMap.withDataMixin({
37-
['%s.yml' % name]: $.util.manifestYaml($.grafana_datasource(name, url, default, method)),
37+
['%s.yml' % name]: $.util.manifestYaml({
38+
apiVersion: 1,
39+
datasources: [$.grafana_datasource(name, url, default, method)],
40+
}),
3841
}),
3942

4043
// Generates yaml string containing datasource config
@@ -63,13 +66,16 @@
6366
*/
6467
grafana_add_datasource_with_basicauth(name, url, username, password, default=false, method='GET')::
6568
configMap.withDataMixin({
66-
['%s.yml' % name]: $.util.manifestYaml($.grafana_datasource_with_basicauth(name, url, username, password, default, method)),
69+
['%s.yml' % name]: $.util.manifestYaml({
70+
apiVersion: 1,
71+
datasources: [$.grafana_datasource_with_basicauth(name, url, username, password, default, method)],
72+
}),
6773
}),
6874

6975
grafana_datasource_config_map:
7076
configMap.new('grafana-datasources') +
7177
configMap.withDataMixin({
72-
[name]: (
78+
[if std.endsWith(name, '.yml') then name else name + '.yml']: (
7379
if std.isString($.grafanaDatasources[name]) then
7480
$.grafanaDatasources[name]
7581
else

0 commit comments

Comments
 (0)