diff --git a/jsonnet/kube-prometheus/main.libsonnet b/jsonnet/kube-prometheus/main.libsonnet index ddb241d823ff52995e8cfb3627c00dd294872fbe..1c13b7b9d0744404ed405ba4a0869f61b6bc6e00 100644 --- a/jsonnet/kube-prometheus/main.libsonnet +++ b/jsonnet/kube-prometheus/main.libsonnet @@ -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 diff --git a/jsonnet/kube-prometheus/platforms/platforms.libsonnet b/jsonnet/kube-prometheus/platforms/platforms.libsonnet index 9c6f07c7ecfb9d4c53fe21c9f23412bd82b92434..979190f21e62040a68073b23238bb983bee24cd9 100644 --- a/jsonnet/kube-prometheus/platforms/platforms.libsonnet +++ b/jsonnet/kube-prometheus/platforms/platforms.libsonnet @@ -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, }