Skip to content

Commit

Permalink
Merge branch 'feat/add-version-overrides' into 'main'
Browse files Browse the repository at this point in the history
Add app+chart version overrides

See merge request henrywhitaker3/generic-helm-chart!3
  • Loading branch information
henrywhitaker3 committed Jan 23, 2024
2 parents 922f381 + 5110b3c commit d21b341
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.3.2
version: 1.3.3
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
Expand Down
6 changes: 3 additions & 3 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ If release name contains chart name it will be used as a full name.
Create chart name and version as used by the chart label.
*/}}
{{- define "generic.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- printf "%s-%s" .Chart.Name (default .Chart.Version .Values.versionOverride) | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Expand All @@ -36,8 +36,8 @@ Common labels
{{- define "generic.labels" -}}
helm.sh/chart: {{ include "generic.chart" . }}
{{ include "generic.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- if or (.Chart.AppVersion) (.Values.appVersionOverride) }}
app.kubernetes.io/version: {{ default .Chart.AppVersion .Values.appVersionOverride | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
Expand Down
23 changes: 23 additions & 0 deletions chart/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,26 @@ tests:
path: .spec.template.spec.containers[0].readinessProbe.exec.command
content:
tail
- it: sets the app version according to the chart
chart:
version: "1.3.2"
appVersion: "1.16.0"
asserts:
- isSubset:
path: .metadata.labels
content:
helm.sh/chart: generic-1.3.2
app.kubernetes.io/version: "1.16.0"
- it: sets the app version according to the overrides
chart:
version: 1.3.2
appVersion: "1.16.0"
set:
versionOverride: 11.0.0
appVersionOverride: "2.0.0"
asserts:
- isSubset:
path: .metadata.labels
content:
helm.sh/chart: generic-11.0.0
app.kubernetes.io/version: "2.0.0"
5 changes: 5 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
nameOverride: ""
fullnameOverride: ""

# Override the chart version
versionOverride: ""
# Override the app version
appVersionOverride: ""

replicaCount: 1

image:
Expand Down

0 comments on commit d21b341

Please sign in to comment.