Skip to content

Commit 434b6ee

Browse files
feat: template helm image properties (#210)
* template image properties * fix broken template * update image-name for push to ttl.sh
1 parent 5dea5a3 commit 434b6ee

File tree

5 files changed

+51
-4
lines changed

5 files changed

+51
-4
lines changed

.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
uses: ./.github/actions/build-push-action
4545
with:
4646
context: deploy
47-
image-name: ttl.sh/automated-${{ github.run_id }}/replicated-sdk:24h
47+
image-name: ttl.sh/automated-${{ github.run_id }}/replicated/replicated-sdk:24h
4848
git-tag: ${{ github.sha }}
4949

5050
- name: Build replicated chart

.github/workflows/publish.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ jobs:
126126
- name: Run Package and Publish
127127
env:
128128
REPLICATED_TAG: v${{needs.get-tags.outputs.tag}}
129-
REPLICATED_REGISTRY: replicated # docker.io/replicated
129+
REPLICATED_REGISTRY: docker.io
130130
REPLICATED_CHART_NAME: replicated
131131
REPLICATED_CHART_VERSION: ${{needs.get-tags.outputs.tag}}
132132
REPLICATED_USER_STAGING: ${{secrets.REPLICATED_USER_STAGING}}

chart/templates/_helpers.tpl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,34 @@ app.kubernetes.io/name: {{ include "replicated.name" . }}
4343
app.kubernetes.io/instance: {{ .Release.Name }}
4444
{{- end }}
4545

46+
{{/*
47+
Image
48+
*/}}
49+
{{- define "replicated.image" -}}
50+
{{- $registryName := default .Values.image.registry ((.Values.global).imageRegistry) -}}
51+
{{- $repositoryName := .Values.image.repository -}}
52+
{{- $separator := ":" -}}
53+
{{- $termination := "" -}}
54+
55+
{{- if not $repositoryName -}}
56+
{{- fail "Image repository is required but not set" -}}
57+
{{- end -}}
58+
59+
{{- if .Values.image.tag -}}
60+
{{- $termination = .Values.image.tag | toString -}}
61+
{{- else if .Chart -}}
62+
{{- $termination = .Chart.AppVersion | default "latest" | toString -}}
63+
{{- else -}}
64+
{{- $termination = "latest" -}}
65+
{{- end -}}
66+
67+
{{- if $registryName -}}
68+
{{- printf "%s/%s%s%s" $registryName $repositoryName $separator $termination -}}
69+
{{- else -}}
70+
{{- printf "%s%s%s" $repositoryName $separator $termination -}}
71+
{{- end -}}
72+
{{- end -}}
73+
4674
{{/*
4775
License Fields
4876
*/}}

chart/templates/replicated-deployment.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,13 @@ spec:
5656
{{- end }}
5757
containers:
5858
- name: replicated
59+
{{- if .Values.images }}
5960
image: {{ index .Values.images "replicated-sdk" }}
6061
imagePullPolicy: IfNotPresent
62+
{{- else }}
63+
image: {{ include "replicated.image" . }}
64+
imagePullPolicy: {{ .Values.image.pullPolicy | default "IfNotPresent" }}
65+
{{- end }}
6166
{{- if .Values.containerSecurityContext.enabled }}
6267
securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 10 }}
6368
{{- end }}

chart/values.yaml.tmpl

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,22 @@
22
# This is a YAML-formatted file.
33
# Declare variables to be passed into your templates.
44

5-
images:
6-
replicated-sdk: ${REPLICATED_REGISTRY}/replicated-sdk:${REPLICATED_TAG}
5+
global:
6+
imageRegistry: ""
7+
8+
# Deprecated: Use .Values.image instead of .Values.images
9+
# The following properties for the Replicated SDK image are deprecated:
10+
#
11+
# images:
12+
# replicated-sdk: ${REPLICATED_REGISTRY}/replicated/replicated-sdk:${REPLICATED_TAG}
13+
14+
# Replicated SDK image properties
15+
# If .Values.images is set, it takes precedence over the following settings.
16+
image:
17+
registry: ${REPLICATED_REGISTRY}
18+
repository: "replicated/replicated-sdk"
19+
tag: "${REPLICATED_TAG}"
20+
pullPolicy: IfNotPresent
721

822
license: ""
923
licenseFields: ""

0 commit comments

Comments
 (0)