Skip to content

Commit 5b1e47e

Browse files
feat: checksum annotations (#938) (#942)
1 parent 130d6fb commit 5b1e47e

16 files changed

+81
-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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
- exists:
19+
path: spec.template.metadata.annotations["checksum/config-argo-gateway"]
20+
template: argo-gateway/deployment.yaml
21+
- exists:
22+
path: spec.template.metadata.annotations["checksum/config-event-reporter"]
23+
template: event-reporters/cluster-event-reporter/deployment.yaml
24+
- exists:
25+
path: spec.template.metadata.annotations["checksum/config-argocd"]
26+
template: event-reporters/cluster-event-reporter/deployment.yaml
27+
- exists:
28+
path: spec.template.metadata.annotations["checksum/config-cap-app-proxy"]
29+
template: app-proxy/deployment.yaml

0 commit comments

Comments
 (0)