Skip to content

Commit 3fed8db

Browse files
authored
Support dynamic templating in qtodo app (#87)
Signed-off-by: Andrew Block <andy.block@gmail.com>
1 parent ed23336 commit 3fed8db

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{/*
2+
Create the image path for the passed in image field
3+
*/}}
4+
{{- define "qtodo.image" -}}
5+
{{- if eq (substr 0 7 .version) "sha256:" -}}
6+
{{- printf "%s@%s" (tpl .name .) (tpl .version .) -}}
7+
{{- else -}}
8+
{{- printf "%s:%s" (tpl .name .) (tpl .version .) -}}
9+
{{- end -}}
10+
{{- end -}}

charts/qtodo/templates/app-deployment.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ spec:
2929
{{- if eq .Values.app.spire.enabled true }}
3030
initContainers:
3131
- name: init-spiffe-helper
32-
image: {{ .Values.app.images.spiffeHelper.name }}:{{ .Values.app.images.spiffeHelper.tag }}
32+
image: {{ template "qtodo.image" .Values.app.images.spiffeHelper }}
3333
imagePullPolicy: {{ .Values.app.images.spiffeHelper.pullPolicy }}
3434
args:
3535
- '-config'
@@ -46,7 +46,7 @@ spec:
4646
- name: svids
4747
mountPath: /svids
4848
- name: init-spiffe-vault-client
49-
image: {{ .Values.app.images.spiffeVaultClient.name }}:{{ .Values.app.images.spiffeVaultClient.tag }}
49+
image: {{ template "qtodo.image" .Values.app.images.spiffeVaultClient }}
5050
imagePullPolicy: {{ .Values.app.images.spiffeVaultClient.pullPolicy }}
5151
command:
5252
- python3
@@ -76,7 +76,7 @@ spec:
7676
containers:
7777
{{- if and .Values.app.spire.enabled .Values.app.spire.sidecars }}
7878
- name: spiffe-helper
79-
image: {{ .Values.app.images.spiffeHelper.name }}:{{ .Values.app.images.spiffeHelper.tag }}
79+
image: {{ template "qtodo.image" .Values.app.images.spiffeHelper }}
8080
imagePullPolicy: {{ .Values.app.images.spiffeHelper.pullPolicy }}
8181
args:
8282
- '-config'
@@ -93,7 +93,7 @@ spec:
9393
- name: svids
9494
mountPath: /svids
9595
- name: spiffe-vault-client
96-
image: {{ .Values.app.images.spiffeVaultClient.name }}:{{ .Values.app.images.spiffeVaultClient.tag }}
96+
image: {{ template "qtodo.image" .Values.app.images.spiffeVaultClient }}
9797
imagePullPolicy: {{ .Values.app.images.spiffeVaultClient.pullPolicy }}
9898
command:
9999
- python3
@@ -124,7 +124,7 @@ spec:
124124
readOnly: true
125125
{{- end }}
126126
- name: qtodo
127-
image: {{ .Values.app.images.main.name }}:{{ .Values.app.images.main.tag }}
127+
image: {{ template "qtodo.image" .Values.app.images.main }}
128128
imagePullPolicy: {{ .Values.app.images.main.pullPolicy }}
129129
ports:
130130
- containerPort: 8080

charts/qtodo/templates/postgresql-statefulset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
spec:
2626
containers:
2727
- name: postgres
28-
image: registry.redhat.io/rhel8/postgresql-16
28+
image: {{ template "qtodo.image" .Values.app.images.postgresql }}
2929
imagePullPolicy: IfNotPresent
3030
env:
3131
- name: POSTGRESQL_DATABASE

charts/qtodo/values.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ app:
1111
images:
1212
main:
1313
name: quay.io/validatedpatterns/qtodo
14-
tag: latest
14+
version: latest
1515
# Modified to Always to force a pull so we can test changes to the container image without requiring manual deletion of images or restarts of argo
1616
pullPolicy: Always
1717
registry:
@@ -23,11 +23,15 @@ app:
2323
passwordVaultKey: password
2424
spiffeHelper:
2525
name: ghcr.io/spiffe/spiffe-helper
26-
tag: 0.10.1
26+
version: 0.10.1
2727
pullPolicy: IfNotPresent
2828
spiffeVaultClient:
2929
name: registry.redhat.io/ubi9/python-311
30-
tag: latest
30+
version: latest
31+
pullPolicy: IfNotPresent
32+
postgresql:
33+
name: registry.redhat.io/rhel8/postgresql-16
34+
version: latest
3135
pullPolicy: IfNotPresent
3236

3337
oidc:

values-hub.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,9 @@ clusterGroup:
351351
value: secret/data/global/qtodo
352352
# For UC-02, we changed the qtodo image to use the one built in the secure supply chain
353353
# - name: app.images.main.name
354-
# value: quay-registry-quay-quay-enterprise.apps.hub.example.com/org/qtodo
354+
# value: quay-registry-quay-quay-enterprise.apps.{{ $.Values.global.clusterDomain }}/ztvp/qtodo
355+
# - name: app.images.main.version
356+
# value: latest
355357
# Uncomment to enable registry authentication
356358
# - name: app.images.main.registry.auth
357359
# value: true

0 commit comments

Comments
 (0)