|
12 | 12 | grafanaDatasources+:: {}, |
13 | 13 |
|
14 | 14 | // 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, |
30 | 25 | }, |
| 26 | + }, |
31 | 27 |
|
32 | 28 | /* |
33 | 29 | helper to allow adding datasources directly to the datasource_config_map |
|
38 | 34 | */ |
39 | 35 | grafana_add_datasource(name, url, default=false, method='GET'):: |
40 | 36 | configMap.withDataMixin({ |
41 | | - ['%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 | + }), |
42 | 41 | }), |
43 | 42 |
|
44 | 43 | // 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 | | - }], |
| 44 | + grafana_datasource_with_basicauth(name, url, username, password, default=false, method='GET', type='prometheus'):: { |
| 45 | + name: name, |
| 46 | + type: type, |
| 47 | + access: 'proxy', |
| 48 | + url: url, |
| 49 | + isDefault: default, |
| 50 | + version: 1, |
| 51 | + editable: false, |
| 52 | + basicAuth: true, |
| 53 | + basicAuthUser: username, |
| 54 | + basicAuthPassword: password, |
| 55 | + jsonData: { |
| 56 | + httpMethod: method, |
63 | 57 | }, |
| 58 | + }, |
64 | 59 |
|
65 | 60 | /* |
66 | 61 | helper to allow adding datasources directly to the datasource_config_map |
|
71 | 66 | */ |
72 | 67 | grafana_add_datasource_with_basicauth(name, url, username, password, default=false, method='GET'):: |
73 | 68 | configMap.withDataMixin({ |
74 | | - ['%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 | + }), |
75 | 73 | }), |
76 | 74 |
|
77 | 75 | grafana_datasource_config_map: |
78 | 76 | configMap.new('grafana-datasources') + |
79 | 77 | configMap.withDataMixin({ |
80 | | - [name]: ( |
| 78 | + [if std.endsWith(name, '.yml') then name else name + '.yml']: ( |
81 | 79 | if std.isString($.grafanaDatasources[name]) then |
82 | 80 | $.grafanaDatasources[name] |
83 | 81 | else |
84 | | - $.util.manifestYaml($.grafanaDatasources[name]) |
| 82 | + $.util.manifestYaml({ |
| 83 | + apiVersion: 1, |
| 84 | + datasources: [$.grafanaDatasources[name]], |
| 85 | + }) |
85 | 86 | ) |
86 | 87 | for name in std.objectFields($.grafanaDatasources) |
87 | 88 | }) + |
|
0 commit comments