Skip to content
Snippets Groups Projects
Commit 0268128b authored by Adin Hodovic's avatar Adin Hodovic
Browse files

Add External mixin library

Add library for mixins
parent f5f72e1b
No related branches found
No related tags found
No related merge requests found
local defaults = {
name: error 'provide name',
namespace: 'monitoring',
labels: {
prometheus: 'k8s',
},
mixin: error 'provide a mixin',
};
function(params) {
config:: defaults + params,
local m = self,
local prometheusRules = if std.objectHasAll(m.config.mixin, 'prometheusRules') || std.objectHasAll(m.config.mixin, 'prometheusAlerts') then {
apiVersion: 'monitoring.coreos.com/v1',
kind: 'PrometheusRule',
metadata: {
labels: m.config.labels,
name: m.config.name,
namespace: m.config.namespace,
},
spec: {
local r = if std.objectHasAll(m.config.mixin, 'prometheusRules') then m.config.mixin.prometheusRules.groups else [],
local a = if std.objectHasAll(m.config.mixin, 'prometheusAlerts') then m.config.mixin.prometheusAlerts.groups else [],
groups: a + r,
},
},
local grafanaDashboards = if std.objectHasAll(m.config.mixin, 'grafanaDashboards') then (
if std.objectHas(m.config, 'dashboardFolder') then {
[m.config.dashboardFolder]+: m.config.mixin.grafanaDashboards,
} else (m.config.mixin.grafanaDashboards)
),
prometheusRules: prometheusRules,
grafanaDashboards: grafanaDashboards,
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment