Skip to content

Commit

Permalink
fix: crop the version label to the kubernetes max length
Browse files Browse the repository at this point in the history
  • Loading branch information
claudioscalzo committed Jan 7, 2024
1 parent ed204b4 commit a48b7f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions operations/helm/charts/grafana-agent/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
-------------------
Expand Down
6 changes: 4 additions & 2 deletions operations/helm/charts/grafana-agent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit a48b7f6

Please sign in to comment.