Skip to content

Commit 30dca95

Browse files
feat: checksum annotations (#938)
1 parent 6b70b12 commit 30dca95

16 files changed

+130
-12
lines changed

charts/gitops-runtime/templates/app-proxy/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
{{- $_ := set $appProxyContext.Values "redis" (get .Values "redis") }}
77
{{- $_ := set $appProxyContext.Values "redis-ha" (get .Values "redis-ha") }}
88

9+
{{- $_ := set $appProxyContext.Values.podAnnotations "checksum/config-codefresh-cm" (include (print $.Template.BasePath "/codefresh-cm.yaml") . | sha256sum) }}
10+
{{- $_ := set $appProxyContext.Values.podAnnotations "checksum/config-cap-app-proxy" (include (print $.Template.BasePath "/app-proxy/config.yaml") . | sha256sum) }}
11+
912
{{/* Merge environment variables with the ones in _app-proxy-env.yaml */}}
1013
{{- $mainContainerMergedValues := mergeOverwrite $appProxyContext.Values.env (include "codefresh-gitops-runtime.app-proxy.calculated-env-vars" . | fromYaml) }}
1114
{{- $_ := set $appProxyContext.Values "env" $mainContainerMergedValues }}

charts/gitops-runtime/templates/argo-gateway/configmap.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,3 @@ metadata:
1515
{{- include "argo-gateway.labels" . | nindent 4 }}
1616
data:
1717
{{- $mergedConfig | toYaml | nindent 2 }}
18-
{{- if index .Values "argo-cd" "enabled" }}
19-
foo: bar
20-
{{- else }}
21-
baz: qux
22-
{{- end }}

charts/gitops-runtime/templates/argo-gateway/deployment.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ spec:
2121
{{- include "argo-gateway.selectorLabels" . | nindent 6 }}
2222
template:
2323
metadata:
24-
{{- with $context.Values.podAnnotations }}
2524
annotations:
25+
checksum/config-argo-gateway: {{ include (print $.Template.BasePath "/argo-gateway/configmap.yaml") . | sha256sum }}
26+
checksum/config-codefresh-cm: {{ include (print $.Template.BasePath "/codefresh-cm.yaml") . | sha256sum }}
27+
{{- with $context.Values.podAnnotations }}
2628
{{- toYaml . | nindent 8 }}
2729
{{- end }}
2830
labels:

charts/gitops-runtime/templates/event-reporters/cluster-event-reporter/deployment.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ spec:
2525
{{- include "cluster-event-reporter.selectorLabels" . | nindent 6 }}
2626
template:
2727
metadata:
28-
{{- with $context.Values.podAnnotations }}
2928
annotations:
29+
checksum/config-event-reporter: {{ include (print $.Template.BasePath "/event-reporters/cluster-event-reporter/configmap.yaml") . | sha256sum }}
30+
checksum/config-codefresh-cm: {{ include (print $.Template.BasePath "/codefresh-cm.yaml") . | sha256sum }}
31+
{{- if index .Values "argo-cd" "enabled" }}
32+
checksum/config-argocd: {{ include ("argo-cd.config.params") (index .Subcharts "argo-cd") | sha256sum }}
33+
{{- end }}
34+
{{- with $context.Values.podAnnotations }}
3035
{{- toYaml . | nindent 8 }}
3136
{{- end }}
3237
labels:

charts/gitops-runtime/templates/event-reporters/runtime-event-reporter/deployment.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ spec:
2525
{{- include "runtime-event-reporter.selectorLabels" . | nindent 6 }}
2626
template:
2727
metadata:
28-
{{- with $context.Values.podAnnotations }}
2928
annotations:
29+
checksum/config-event-reporter: {{ include (print $.Template.BasePath "/event-reporters/runtime-event-reporter/configmap.yaml") . | sha256sum }}
30+
checksum/config-codefresh-cm: {{ include (print $.Template.BasePath "/codefresh-cm.yaml") . | sha256sum }}
31+
{{- if index .Values "argo-cd" "enabled" }}
32+
checksum/config-argocd: {{ include ("argo-cd.config.params") (index .Subcharts "argo-cd") | sha256sum }}
33+
{{- end }}
34+
{{- with $context.Values.podAnnotations }}
3035
{{- toYaml . | nindent 8 }}
3136
{{- end }}
3237
labels:

charts/gitops-runtime/tests/app-proxy-hosted_test.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ suite: Test hosted runtime flow in app-proxy
22
templates:
33
- app-proxy/deployment.yaml
44
- app-proxy/config.yaml
5+
- _components/cap-app-proxy/_deployment.yaml
6+
- _components/cap-app-proxy/_config.yaml
7+
- codefresh-cm.yaml
58
tests:
69
- it: accountId appears in app-proxy env if provided - used in hosted
710
template: 'app-proxy/deployment.yaml'
@@ -26,7 +29,7 @@ tests:
2629
global.codefresh.accountId: ""
2730
asserts:
2831
- failedTemplate:
29-
errorMessage: 'global.codefresh.accountId must be provided for hosted runtimes'
32+
errorMessage: 'global.codefresh.accountId is required for tunnel based runtime'
3033

3134
- it: accountId appears in app-proxy env and runtime type is HELM_HOSTED
3235
template: 'app-proxy/deployment.yaml'
@@ -66,4 +69,4 @@ tests:
6669
path: spec.template.spec.containers[0].env
6770
content:
6871
name: INSTALLATION_TYPE
69-
value: "HELM_HOSTED"
72+
value: "HELM_HOSTED"

charts/gitops-runtime/tests/app-proxy-image-enrichemnt_test.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ templates:
55
- app-proxy/enrichment/sa.yaml
66
- app-proxy/enrichment/rbac.yaml
77
- app-proxy/enrichment/enforce-workflows-enabled.yaml
8+
- _components/cap-app-proxy/_deployment.yaml
9+
- _components/cap-app-proxy/_config.yaml
10+
- codefresh-cm.yaml
811
tests:
912
- it: Fail template if enrichment is enabled and workflows disabled
1013
template: 'app-proxy/enrichment/enforce-workflows-enabled.yaml'

charts/gitops-runtime/tests/app-proxy-misc_test.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ suite: misc tests on app-proxy templates generation
33
templates:
44
- app-proxy/deployment.yaml
55
- app-proxy/config.yaml
6+
- _components/cap-app-proxy/_deployment.yaml
7+
- _components/cap-app-proxy/_config.yaml
8+
- codefresh-cm.yaml
69
tests:
710
- it: overriding of environment variables on main container
811
template: 'app-proxy/deployment.yaml'
@@ -222,7 +225,7 @@ tests:
222225
mountPath: /my-secret
223226

224227
- it: Fail template if runtime name not provided
225-
template: 'app-proxy/config.yaml'
228+
template: 'app-proxy/deployment.yaml'
226229
set:
227230
global.codefresh.userToken.token: dummy
228231
global.codefresh.accountId: asddd

charts/gitops-runtime/tests/argo-api-gateway_test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
suite: argo-gateway tests
33
templates:
44
- argo-gateway/**
5+
- codefresh-cm.yaml
56
tests:
67
- it: Argo Api Gateway ConfigMap should have valid data
78
template: argo-gateway/configmap.yaml
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
2+
suite: checksum tests
3+
templates:
4+
- event-reporters/**/deployment.yaml
5+
- event-reporters/**/configmap.yaml
6+
- argo-gateway/deployment.yaml
7+
- argo-gateway/configmap.yaml
8+
- app-proxy/deployment.yaml
9+
- app-proxy/config.yaml
10+
- _components/cap-app-proxy/_deployment.yaml
11+
- _components/cap-app-proxy/_config.yaml
12+
- codefresh-cm.yaml
13+
tests:
14+
- it: default checksum annotations is present
15+
values:
16+
- ./values/mandatory-values-ingress.yaml
17+
asserts:
18+
- equal:
19+
path: spec.template.metadata.annotations["checksum/config-argo-gateway"]
20+
value: ab112b8010e1534e8b45f746764af03ca4e7c9fa5cd0a01f04830e0a6c6e77e1
21+
template: argo-gateway/deployment.yaml
22+
- equal:
23+
path: spec.template.metadata.annotations["checksum/config-codefresh-cm"]
24+
value: 4fa7b6b4939725018068441ee7ea7ec594c30d6e58020fdaa89b07ca9515b650
25+
template: argo-gateway/deployment.yaml
26+
- equal:
27+
path: spec.template.metadata.annotations["checksum/config-event-reporter"]
28+
value: d016ba2b10b22e24da8854027d4e3fccfe02ee3db4441512ba38a0eb34e124f5
29+
template: event-reporters/cluster-event-reporter/deployment.yaml
30+
- equal:
31+
path: spec.template.metadata.annotations["checksum/config-codefresh-cm"]
32+
value: 4fa7b6b4939725018068441ee7ea7ec594c30d6e58020fdaa89b07ca9515b650
33+
template: event-reporters/cluster-event-reporter/deployment.yaml
34+
- equal:
35+
path: spec.template.metadata.annotations["checksum/config-argocd"]
36+
value: 4ae1efd920b2b1b83a9b74fabd84defe9869f7c66a444bcfd4ce7dbb5cb846c8
37+
template: event-reporters/cluster-event-reporter/deployment.yaml
38+
- equal:
39+
path: spec.template.metadata.annotations["checksum/config-cap-app-proxy"]
40+
value: 8963a9c81220fd8440ccc4e8675be794c83988751fd0d8591c60b2cd3923fbd4
41+
template: app-proxy/deployment.yaml
42+
- equal:
43+
path: spec.template.metadata.annotations["checksum/config-codefresh-cm"]
44+
value: 4fa7b6b4939725018068441ee7ea7ec594c30d6e58020fdaa89b07ca9515b650
45+
template: app-proxy/deployment.yaml
46+
47+
- it: checksum annotations should change when configmap changes
48+
template: argo-gateway/deployment.yaml
49+
set:
50+
argo-cd.enabled: false
51+
global.integrations.argo-cd.server.svc: my-argocd-server
52+
values:
53+
- ./values/mandatory-values-ingress.yaml
54+
asserts:
55+
- equal:
56+
path: spec.template.metadata.annotations["checksum/config-argo-gateway"]
57+
value: 89ba18c028caf3aafa73763816296570ec6d82afafa8744419773a4be6d84aff
58+
template: argo-gateway/deployment.yaml
59+
- equal:
60+
path: spec.template.metadata.annotations["checksum/config-codefresh-cm"]
61+
value: 6fc94d431ae6064fddc76734ec7c66d8b60af02cb22d9b1298e8403a8adcda82
62+
template: argo-gateway/deployment.yaml
63+
- equal:
64+
path: spec.template.metadata.annotations["checksum/config-event-reporter"]
65+
value: e76508c530cbb199da90e2dfee0ecb4b6ce79ed86e2b5368c3d670b5ccc9fbe2
66+
template: event-reporters/cluster-event-reporter/deployment.yaml
67+
- equal:
68+
path: spec.template.metadata.annotations["checksum/config-codefresh-cm"]
69+
value: 6fc94d431ae6064fddc76734ec7c66d8b60af02cb22d9b1298e8403a8adcda82
70+
template: event-reporters/cluster-event-reporter/deployment.yaml
71+
- equal:
72+
path: spec.template.metadata.annotations["checksum/config-cap-app-proxy"]
73+
value: b302ea8929baccb98f9b0086987f76de6e3591e72f356915d951e6a6437611f6
74+
template: app-proxy/deployment.yaml
75+
- equal:
76+
path: spec.template.metadata.annotations["checksum/config-codefresh-cm"]
77+
value: 6fc94d431ae6064fddc76734ec7c66d8b60af02cb22d9b1298e8403a8adcda82
78+
template: app-proxy/deployment.yaml

0 commit comments

Comments
 (0)