Skip to content

Commit c07f92e

Browse files
committed
grizzly: remove .json/.yaml in fromMap/fromMixin
Mixins typically append .json or .yaml at the end of the name. Remove those so that Grizzly can deploy them like the jsonnet code embed into Grizzly does (grizzly.jsonnet). Signed-off-by: Arthur Outhenin-Chalandre <[email protected]>
1 parent 5a128df commit c07f92e

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

grizzly/grafana.libsonnet

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ local util = import 'util.libsonnet';
55
getFolder(main):: util.get(main, 'grafanaDashboardFolder', 'General'),
66

77
fromMap(dashboards, folder):: {
8-
[k]: util.makeResource('Dashboard', k, dashboards[k], { folder: folder })
8+
[k]: util.makeResource(
9+
'Dashboard',
10+
std.strReplace(std.strReplace(std.strReplace(k, '.json', ''), '.yaml', ''), '.yml', ''),
11+
dashboards[k],
12+
{ folder: folder }
13+
)
914
for k in std.objectFields(dashboards)
1015
},
1116

@@ -14,7 +19,12 @@ local util = import 'util.libsonnet';
1419
local mixin = mixins[key];
1520
{
1621
local folder = util.get(mixin, 'grafanaDashboardFolder', 'General'),
17-
[k]: util.makeResource('Dashboard', k, mixin.grafanaDashboards[k], { folder: folder })
22+
[k]: util.makeResource(
23+
'Dashboard',
24+
std.strReplace(std.strReplace(std.strReplace(k, '.json', ''), '.yaml', ''), '.yml', ''),
25+
mixin.grafanaDashboards[k],
26+
{ folder: folder }
27+
)
1828
for k in std.objectFieldsAll(util.get(mixin, 'grafanaDashboards', {}))
1929
}
2030
for key in std.objectFields(mixins)

grizzly/prometheus.libsonnet

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,20 @@ local resource = import 'resource.libsonnet';
1515

1616
fromMapsFiltered(rules, excludes):: {
1717
local filterRules(rules, exclude_list) = [rule for rule in rules.groups if !std.member(exclude_list, rule.name)],
18-
[k]: util.makeResource(kind, k, { groups: filterRules(rules, excludes) }, {})
18+
[k]: util.makeResource(
19+
kind,
20+
std.strReplace(std.strReplace(std.strReplace(k, '.json', ''), '.yaml', ''), '.yml', ''),
21+
{ groups: filterRules(rules, excludes) },
22+
{}
23+
)
1924
for k in std.objectFields(rules)
2025
},
2126

2227
fromMixins(mixins):: {
2328
[if std.objectHasAll(mixins[key], alertRules) || std.objectHasAll(mixins[key], recordingRules) then key else null]:
2429
util.makeResource(
2530
kind,
26-
key,
31+
std.strReplace(std.strReplace(std.strReplace(key, '.json', ''), '.yaml', ''), '.yml', ''),
2732
(if std.objectHasAll(mixins[key], alertRules) then mixins[key].prometheusAlerts else {})
2833
+ (if std.objectHasAll(mixins[key], recordingRules) then mixins[key].prometheusRules else {})
2934
)

0 commit comments

Comments
 (0)