Skip to content

Commit 46bf265

Browse files
fix: prevent running helm chart without valid tag (#3770)
Co-authored-by: Eric Paulsen <ericpaulsen@coder.com>
1 parent 4c18034 commit 46bf265

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

helm/Chart.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ home: https://github.com/coder/coder
55

66
# version and appVersion are injected at release and will always be shown as
77
# 0.1.0 in the repository.
8+
#
9+
# If you're installing the Helm chart directly from git it will have this
10+
# version, which means the auto-generated image URI will be invalid. You can set
11+
# "coder.image.tag" to the desired tag manually.
812
type: application
913
version: "0.1.0"
1014
appVersion: "0.1.0"

helm/templates/_helpers.tpl

+10
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
3232
app.kubernetes.io/managed-by: {{ .Release.Service }}
3333
{{- end }}
3434

35+
{{/*
36+
Coder Docker image URI
37+
*/}}
38+
{{- define "coder.image" -}}
39+
{{- if and (eq .Values.coder.image.tag "") (eq .Chart.AppVersion "0.1.0") -}}
40+
{{ fail "You must specify coder.image.tag if you're installing the Helm chart directly from Git." }}
41+
{{- end -}}
42+
{{ .Values.coder.image.repo }}:{{ .Values.coder.image.tag | default (printf "v%v" .Chart.AppVersion) }}
43+
{{- end }}
44+
3545
{{/*
3646
Coder listen port (must be > 1024)
3747
*/}}

helm/templates/coder.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ spec:
2929
terminationGracePeriodSeconds: 60
3030
containers:
3131
- name: coder
32-
image: "{{ .Values.coder.image.repo }}:{{ .Values.coder.image.tag | default (printf "v%v" .Chart.AppVersion) }}"
32+
image: {{ include "coder.image" . | quote }}
3333
imagePullPolicy: {{ .Values.coder.image.pullPolicy }}
3434
resources:
3535
{{- toYaml .Values.resources | nindent 12 }}

helm/values.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ coder:
1010
# coder.image.repo -- The repository of the image.
1111
repo: "ghcr.io/coder/coder"
1212
# coder.image.tag -- The tag of the image, defaults to {{.Chart.AppVersion}}
13-
# if not set.
13+
# if not set. If you're using the chart directly from git, the default
14+
# app version will not work and you'll need to set this value. The helm
15+
# chart helpfully fails quickly in this case.
1416
tag: ""
1517
# coder.image.pullPolicy -- The pull policy to use for the image. See:
1618
# https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy

0 commit comments

Comments
 (0)