diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 850373f..e6990b9 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -30,14 +30,22 @@ Create chart name and version as used by the chart label. {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- end }} +{{/* +Resolve the effective Typesense application version. +*/}} +{{- define "typesense.appVersion" -}} +{{- .Values.image.tag | default .Chart.AppVersion -}} +{{- end }} + {{/* Common labels */}} {{- define "typesense.labels" -}} helm.sh/chart: {{ include "typesense.chart" . }} {{ include "typesense.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- $appVersion := include "typesense.appVersion" . }} +{{- if $appVersion }} +app.kubernetes.io/version: {{ $appVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- if .Chart.Annotations.team }} @@ -104,4 +112,4 @@ Create the nodeslist {{- $nodes = append $nodes $node }} {{- end }} {{- $nodes | join "," }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/tests/statefulset_test.yaml b/tests/statefulset_test.yaml index 855a242..3f86650 100644 --- a/tests/statefulset_test.yaml +++ b/tests/statefulset_test.yaml @@ -84,6 +84,18 @@ tests: - equal: path: .spec.replicas value: 5 + - it: should use the effective image tag for app version labels when overridden + set: + image: + tag: "26.0" + asserts: + - notFailedTemplate: {} + - equal: + path: .spec.template.metadata.labels["app.kubernetes.io/version"] + value: "26.0" + - equal: + path: .spec.template.spec.containers[0].image + value: typesense/typesense:26.0 - it: should reject even replica counts greater than 1 set: replicaCount: 4