jsonnet: fix test failures with platformPatch

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
This commit is contained in:
Damien Grisonnet
2021-04-09 12:44:51 +02:00
parent b59b2c23d8
commit ed5a2f94fc
2 changed files with 31 additions and 6 deletions

View File

@@ -9,7 +9,7 @@ local prometheusAdapter = import './components/prometheus-adapter.libsonnet';
local prometheusOperator = import './components/prometheus-operator.libsonnet';
local prometheus = import './components/prometheus.libsonnet';
local platformPatch = (import './platforms/platforms.libsonnet').platformPatch;
local platformPatch = import './platforms/platforms.libsonnet';
{
// using `values` as this is similar to helm
@@ -127,5 +127,5 @@ local platformPatch = (import './platforms/platforms.libsonnet').platformPatch;
name: $.values.kubePrometheus.namespace,
},
},
} + platformPatch($.values.kubePrometheus.platform),
}
},
} + platformPatch

View File

@@ -9,8 +9,33 @@ local platforms = {
kubespray: import './kubespray.libsonnet',
};
// platformPatch returns the platform specific patch associated to the given
// platform.
local platformPatch(p) = if p != null && std.objectHas(platforms, p) then platforms[p] else {};
{
// platformPatch returns the platform specific patch associated to the given
// platform.
platformPatch(p): if p != null && std.objectHas(platforms, p) then platforms[p] else {},
// initialize the object to prevent "Indexed object has no field" lint errors
local p = {
alertmanager: {},
blackboxExporter: {},
grafana: {},
kubeStateMetrics: {},
nodeExporter: {},
prometheus: {},
prometheusAdapter: {},
prometheusOperator: {},
kubernetesControlPlane: {},
kubePrometheus: {},
} + platformPatch($.values.kubePrometheus.platform),
alertmanager+: p.alertmanager,
blackboxExporter+: p.blackboxExporter,
grafana+: p.grafana,
kubeStateMetrics+: p.kubeStateMetrics,
nodeExporter+: p.nodeExporter,
prometheus+: p.prometheus,
prometheusAdapter+: p.prometheusAdapter,
prometheusOperator+: p.prometheusOperator,
kubernetesControlPlane+: p.kubernetesControlPlane,
kubePrometheus+: p.kubePrometheus,
}