diff --git a/operations/helm/charts/grafana-agent/CHANGELOG.md b/operations/helm/charts/grafana-agent/CHANGELOG.md index 6a282af74ccf..5fe3b4f148b7 100644 --- a/operations/helm/charts/grafana-agent/CHANGELOG.md +++ b/operations/helm/charts/grafana-agent/CHANGELOG.md @@ -13,6 +13,7 @@ Unreleased ### Bugfixes - Fix a bug preventing the `.Values.configReloader.image.digest` Helm value to be correctly retrieved. (@claudioscalzo) +- Fix a bug preventing digests to be used as labels because of their length. (@claudioscalzo) 0.30.0 (2024-01-05) ------------------- diff --git a/operations/helm/charts/grafana-agent/templates/_helpers.tpl b/operations/helm/charts/grafana-agent/templates/_helpers.tpl index 22fbefc24eec..8cdf15a8dba9 100644 --- a/operations/helm/charts/grafana-agent/templates/_helpers.tpl +++ b/operations/helm/charts/grafana-agent/templates/_helpers.tpl @@ -56,8 +56,10 @@ app.kubernetes.io/version: "vX.Y.Z" app.kubernetes.io/managed-by: {{ .Release.Service }} {{- else }} {{/* substr trims delimeter prefix char from grafana-agent.imageId output - e.g. ':' for tags and '@' for digests. */}} -app.kubernetes.io/version: {{ substr 1 -1 (include "grafana-agent.imageId" .) }} + e.g. ':' for tags and '@' for digests. + For digests, we crop the string to a 7-char sha. */}} +{{- $versionLabelLength := ternary 15 -1 (hasPrefix "@" (include "grafana-agent.imageId" .)) -}} +app.kubernetes.io/version: {{ substr 1 $versionLabelLength (include "grafana-agent.imageId" .) }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end }} {{- end }}