Skip to content

Commit 9614198

Browse files
feat(cf-common): add checksum annotation (#10)
* feat(cf-common): add checksum annotation * add checksum/secret annotation
1 parent 8a53d37 commit 9614198

File tree

6 files changed

+78
-5
lines changed

6 files changed

+78
-5
lines changed

charts/cf-common-test/tests/deployment/metadata_test.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,39 @@ tests:
6666
- equal:
6767
path: spec.template.metadata.annotations.foo
6868
value: bar
69+
70+
- it: Test checksum/config annotation
71+
values:
72+
- values.yaml
73+
set:
74+
podAnnotations:
75+
foo: bar
76+
configMaps:
77+
config:
78+
enabled: true
79+
data:
80+
alice: bob
81+
asserts:
82+
- equal:
83+
path: spec.template.metadata.annotations
84+
value:
85+
foo: bar
86+
checksum/config: 6d1644995a0e1ef705e43f2f737e6adea7036bfceb82cc3bf468cc411a0ff77b
87+
88+
- it: Test checksum/secret annotation
89+
values:
90+
- values.yaml
91+
set:
92+
podAnnotations:
93+
foo: bar
94+
secrets:
95+
secret:
96+
enabled: true
97+
stringData:
98+
alice: bob
99+
asserts:
100+
- equal:
101+
path: spec.template.metadata.annotations
102+
value:
103+
foo: bar
104+
checksum/secret: 8de97c7e45c17e43f84a9bda5428fe0bdf0be8fe12b99cb928c95a01cacfb85f

charts/cf-common/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
appVersion: v0.0.0
33
description: Codefresh library chart
44
name: cf-common
5-
version: 0.0.9
5+
version: 0.0.10
66
type: library
77
keywords:
88
- codefresh

charts/cf-common/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Codefresh library chart
44

5-
![Version: 0.0.9](https://img.shields.io/badge/Version-0.0.9-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: v0.0.0](https://img.shields.io/badge/AppVersion-v0.0.0-informational?style=flat-square)
5+
![Version: 0.0.10](https://img.shields.io/badge/Version-0.0.10-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: v0.0.0](https://img.shields.io/badge/AppVersion-v0.0.0-informational?style=flat-square)
66

77
## Installing the Chart
88

@@ -18,7 +18,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
1818
# Chart.yaml
1919
dependencies:
2020
- name: cf-common
21-
version: 0.0.9
21+
version: 0.0.10
2222
repository: https://chartmuseum.codefresh.io/cf-common
2323
```
2424
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{{/*
2+
Render checksum annotation
3+
Usage:
4+
*/}}
5+
{{- define "cf-common.annotations.podAnnotations" -}}
6+
7+
{{- if .Values.podAnnotations -}}
8+
{{- include "cf-common.tplrender" (dict "Values" .Values.podAnnotations "context" $) | nindent 0 }}
9+
{{- end -}}
10+
11+
{{- $configMapFound := dict -}}
12+
{{- range $configMapIndex, $configMapItem := .Values.configMaps -}}
13+
14+
{{- if $configMapItem.enabled -}}
15+
{{- $_ := set $configMapFound $configMapIndex ( include "cf-common.tplrender" (dict "Values" $configMapItem.data "context" $) | sha256sum) -}}
16+
{{- end -}}
17+
18+
{{- if $configMapFound -}}
19+
{{- printf "checksum/config: %v" (toYaml $configMapFound | sha256sum) | nindent 0 -}}
20+
{{- end -}}
21+
22+
{{- end -}}
23+
24+
{{- $secretFound := dict -}}
25+
{{- range $secretIndex, $secretItem := .Values.secrets -}}
26+
27+
{{- if $secretItem.enabled -}}
28+
{{- $_ := set $secretFound $secretIndex ( include "cf-common.tplrender" (dict "Values" $secretItem.stringData "context" $) | sha256sum) -}}
29+
{{- end -}}
30+
31+
{{- if $secretFound -}}
32+
{{- printf "checksum/secret: %v" (toYaml $secretFound | sha256sum) | nindent 0 -}}
33+
{{- end -}}
34+
35+
{{- end -}}
36+
37+
{{- end -}}

charts/cf-common/templates/controller/_deployment.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ spec:
5151
{{- if .Values.podLabels }}
5252
{{- include "cf-common.tplrender" (dict "Values" .Values.podLabels "context" $) | nindent 8 }}
5353
{{- end }}
54-
{{- if .Values.podAnnotations }}
54+
{{- with include "cf-common.annotations.podAnnotations" . }}
5555
annotations:
56-
{{- include "cf-common.tplrender" (dict "Values" .Values.podAnnotations "context" $) | nindent 8 }}
56+
{{- . | nindent 8}}
5757
{{- end }}
5858
spec: {{- include "cf-common.controller.pod" . | trim | nindent 6 -}}
5959
{{- end -}}

0 commit comments

Comments
 (0)