Skip to content

Commit 09fc210

Browse files
committed
Don't wrap datasources in an array
1 parent 9083a44 commit 09fc210

File tree

1 file changed

+29
-34
lines changed

1 file changed

+29
-34
lines changed

prometheus-ksonnet/grafana/datasources.libsonnet

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,18 @@
1212
grafanaDatasources+:: {},
1313

1414
// Generates yaml string containing datasource config
15-
grafana_datasource(name, url, default=false, method='GET')::
16-
{
17-
apiVersion: 1,
18-
datasources: [{
19-
name: name,
20-
type: 'prometheus',
21-
access: 'proxy',
22-
url: url,
23-
isDefault: default,
24-
version: 1,
25-
editable: false,
26-
jsonData: {
27-
httpMethod: method,
28-
},
29-
}],
15+
grafana_datasource(name, url, default=false, method='GET', type='prometheus'):: {
16+
name: name,
17+
type: type,
18+
access: 'proxy',
19+
url: url,
20+
isDefault: default,
21+
version: 1,
22+
editable: false,
23+
jsonData: {
24+
httpMethod: method,
3025
},
26+
},
3127

3228
/*
3329
helper to allow adding datasources directly to the datasource_config_map
@@ -42,25 +38,21 @@
4238
}),
4339

4440
// Generates yaml string containing datasource config
45-
grafana_datasource_with_basicauth(name, url, username, password, default=false, method='GET')::
46-
{
47-
apiVersion: 1,
48-
datasources: [{
49-
name: name,
50-
type: 'prometheus',
51-
access: 'proxy',
52-
url: url,
53-
isDefault: default,
54-
version: 1,
55-
editable: false,
56-
basicAuth: true,
57-
basicAuthUser: username,
58-
basicAuthPassword: password,
59-
jsonData: {
60-
httpMethod: method,
61-
},
62-
}],
41+
grafana_datasource_with_basicauth(name, url, username, password, default=false, method='GET', type='prometheus'):: {
42+
name: name,
43+
type: type,
44+
access: 'proxy',
45+
url: url,
46+
isDefault: default,
47+
version: 1,
48+
editable: false,
49+
basicAuth: true,
50+
basicAuthUser: username,
51+
basicAuthPassword: password,
52+
jsonData: {
53+
httpMethod: method,
6354
},
55+
},
6456

6557
/*
6658
helper to allow adding datasources directly to the datasource_config_map
@@ -81,7 +73,10 @@
8173
if std.isString($.grafanaDatasources[name]) then
8274
$.grafanaDatasources[name]
8375
else
84-
$.util.manifestYaml($.grafanaDatasources[name])
76+
$.util.manifestYaml({
77+
apiVersion: 1,
78+
datasources: [$.grafanaDatasources[name]],
79+
})
8580
)
8681
for name in std.objectFields($.grafanaDatasources)
8782
}) +

0 commit comments

Comments
 (0)