Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/prometheus-node-exporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ keywords:
- prometheus
- exporter
type: application
version: 4.56.1
version: 4.56.2
# renovate: github=prometheus/node_exporter
appVersion: 1.12.1
home: https://github.com/prometheus/node_exporter/
Expand Down
25 changes: 24 additions & 1 deletion charts/prometheus-node-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,17 @@ Create the name of the service account to use
{{- end }}

{{/*
The image to use
The image to use.

If image.tag contains "/", treat it as a full image reference (optionally with
@digest) and use it as-is. Prefer image.registry/repository/tag (+ image.digest)
for the normal case.
*/}}
{{- define "prometheus-node-exporter.image" -}}
{{- if .Values.image.sha }}
{{- fail "image.sha forbidden. Use image.digest instead" }}
{{- else if and .Values.image.tag (contains "/" (.Values.image.tag | toString)) }}
{{- .Values.image.tag }}
{{- else if .Values.image.digest }}
{{- if .Values.global.imageRegistry }}
{{- printf "%s/%s:%s%s@%s" .Values.global.imageRegistry .Values.image.repository (default (printf "v%s" .Chart.AppVersion) .Values.image.tag) (ternary "-distroless" "" .Values.image.distroless) .Values.image.digest }}
Expand All @@ -92,6 +98,23 @@ The image to use
{{- end }}
{{- end }}

{{/*
Semver used for feature gates (semverCompare). Prefers Values.version, then
image.tag, then Chart.AppVersion. Normalizes common image-ref forms:
- tag@sha256:...
- registry/repository:tag[@digest]
- registry:port/repository:tag[@digest]
*/}}
{{- define "prometheus-node-exporter.appSemver" -}}
{{- $raw := coalesce .Values.version .Values.image.tag .Chart.AppVersion | toString -}}
{{- $noDigest := ternary (index (splitList "@" $raw) 0) $raw (contains "@" $raw) -}}
{{- if contains "/" $noDigest -}}
{{- last (splitList ":" $noDigest) -}}
{{- else -}}
{{- $noDigest -}}
{{- end -}}
{{- end -}}

{{/*
Allow the release namespace to be overridden for multi-namespace deployments in combined charts
*/}}
Expand Down
2 changes: 1 addition & 1 deletion charts/prometheus-node-exporter/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ spec:
- --path.sysfs=/host/sys
{{- if .Values.hostRootFsMount.enabled }}
- --path.rootfs=/host/root
{{- if semverCompare ">=1.4.0-0" (coalesce .Values.version .Values.image.tag .Chart.AppVersion) }}
{{- if semverCompare ">=1.4.0-0" (include "prometheus-node-exporter.appSemver" .) }}
- --path.udev.data=/host/root/run/udev/data
{{- end }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: daemonset image and semver feature gates
templates:
- daemonset.yaml
tests:
- it: includes udev path arg with default chart appVersion
asserts:
- contains:
path: spec.template.spec.containers[0].args
content: --path.udev.data=/host/root/run/udev/data
- equal:
path: spec.template.spec.containers[0].image
value: quay.io/prometheus/node-exporter:v1.12.1

- it: includes udev path arg when image.tag has digest pin
set:
image.tag: v1.12.1@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
asserts:
- contains:
path: spec.template.spec.containers[0].args
content: --path.udev.data=/host/root/run/udev/data
- equal:
path: spec.template.spec.containers[0].image
value: quay.io/prometheus/node-exporter:v1.12.1@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

- it: includes udev path arg and uses full image ref from image.tag
set:
image.tag: quay.io/prometheus/node-exporter:v1.6.0@sha256:d2e48098c364e61ee62d9016eed863b66331d87cf67146f2068b70ed9d9b4f98
asserts:
- contains:
path: spec.template.spec.containers[0].args
content: --path.udev.data=/host/root/run/udev/data
- equal:
path: spec.template.spec.containers[0].image
value: quay.io/prometheus/node-exporter:v1.6.0@sha256:d2e48098c364e61ee62d9016eed863b66331d87cf67146f2068b70ed9d9b4f98

- it: omits udev path arg when app semver is below 1.4.0
set:
image.tag: v1.3.1
asserts:
- notContains:
path: spec.template.spec.containers[0].args
content: --path.udev.data=/host/root/run/udev/data

- it: uses Values.version for feature gate when image.tag is not semver
set:
image.tag: latest
version: 1.12.1
asserts:
- contains:
path: spec.template.spec.containers[0].args
content: --path.udev.data=/host/root/run/udev/data
- equal:
path: spec.template.spec.containers[0].image
value: quay.io/prometheus/node-exporter:latest
4 changes: 3 additions & 1 deletion charts/prometheus-node-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -646,5 +646,7 @@ extraVolumeMounts: []
# mountPath: /extra
# readOnly: true

# Override version of app, required if image.tag is defined and does not follow semver
# Override app version for feature gates when image.tag is not a plain semver
# (for example "latest"). Digests and full image refs in image.tag are normalized
# automatically for comparison; use image.digest when pinning with registry/repository.
version: ""