Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kube-prometheus-stack] Add downward compat for Prom CRD #4906

2 changes: 1 addition & 1 deletion charts/kube-prometheus-stack/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ name: kube-prometheus-stack
sources:
- https://github.com/prometheus-community/helm-charts
- https://github.com/prometheus-operator/kube-prometheus
version: 65.2.0
version: 65.3.0
appVersion: v0.77.1
kubeVersion: ">=1.19.0-0"
home: https://github.com/prometheus-operator/kube-prometheus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@ spec:
scrapeConfigSelector:
matchLabels:
release: {{ $.Release.Name | quote }}
{{ else }}
{{ else if ne .Values.prometheus.prometheusSpec.scrapeConfigSelector nil }}
scrapeConfigSelector: {}
{{- end }}
{{- if .Values.prometheus.prometheusSpec.scrapeConfigNamespaceSelector }}
scrapeConfigNamespaceSelector:
{{ tpl (toYaml .Values.prometheus.prometheusSpec.scrapeConfigNamespaceSelector | indent 4) . }}
{{ else }}
{{ else if ne .Values.prometheus.prometheusSpec.scrapeConfigNamespaceSelector nil }}
scrapeConfigNamespaceSelector: {}
{{- end }}
{{- if .Values.prometheus.prometheusSpec.storageSpec }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: test scrapeConfigNamespaceSelector
templates:
- prometheus/prometheus.yaml
tests:
- it: should be empty by default
asserts:
- equal:
path: spec.scrapeConfigNamespaceSelector
value: {}
- it: should be set to a specific label
set:
prometheus:
prometheusSpec:
scrapeConfigNamespaceSelector:
matchLabels:
abc: def
asserts:
- equal:
path: spec.scrapeConfigNamespaceSelector.matchLabels.abc
value: def
- it: should be ignored, if set to null
set:
prometheus:
prometheusSpec:
scrapeConfigNamespaceSelector: null
asserts:
- notExists:
path: spec.scrapeConfigNamespaceSelector
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: test scrapeConfigSelector
templates:
- prometheus/prometheus.yaml
tests:
- it: should match the release name by default
asserts:
- equal:
path: spec.scrapeConfigSelector.matchLabels.release
value: RELEASE-NAME
- it: should be set to a specific label
set:
prometheus:
prometheusSpec:
scrapeConfigSelector:
abc: def
asserts:
- equal:
path: spec.scrapeConfigSelector
value:
abc: def
- it: should be set to a specific label
set:
prometheus:
prometheusSpec:
scrapeConfigSelector:
matchLabels:
abc: def
asserts:
- equal:
path: spec.scrapeConfigSelector.matchLabels.abc
value: def
- it: should be ignored, if set to null
set:
prometheus:
prometheusSpec:
scrapeConfigSelector: null
scrapeConfigSelectorNilUsesHelmValues: null
asserts:
- notExists:
path: spec.scrapeConfigSelector
Loading