diff --git a/charts/cf-common-test/tests/deployment/metadata_test.yaml b/charts/cf-common-test/tests/deployment/metadata_test.yaml index 1dc0a9cd..6ac74786 100644 --- a/charts/cf-common-test/tests/deployment/metadata_test.yaml +++ b/charts/cf-common-test/tests/deployment/metadata_test.yaml @@ -66,3 +66,39 @@ tests: - equal: path: spec.template.metadata.annotations.foo value: bar + + - it: Test checksum/config annotation + values: + - values.yaml + set: + podAnnotations: + foo: bar + configMaps: + config: + enabled: true + data: + alice: bob + asserts: + - equal: + path: spec.template.metadata.annotations + value: + foo: bar + checksum/config: 6d1644995a0e1ef705e43f2f737e6adea7036bfceb82cc3bf468cc411a0ff77b + + - it: Test checksum/secret annotation + values: + - values.yaml + set: + podAnnotations: + foo: bar + secrets: + secret: + enabled: true + stringData: + alice: bob + asserts: + - equal: + path: spec.template.metadata.annotations + value: + foo: bar + checksum/secret: 8de97c7e45c17e43f84a9bda5428fe0bdf0be8fe12b99cb928c95a01cacfb85f diff --git a/charts/cf-common/Chart.yaml b/charts/cf-common/Chart.yaml index 210f815f..903c6606 100644 --- a/charts/cf-common/Chart.yaml +++ b/charts/cf-common/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 appVersion: v0.0.0 description: Codefresh library chart name: cf-common -version: 0.0.9 +version: 0.0.10 type: library keywords: - codefresh diff --git a/charts/cf-common/README.md b/charts/cf-common/README.md index 9e73ed4b..7d300b71 100644 --- a/charts/cf-common/README.md +++ b/charts/cf-common/README.md @@ -2,7 +2,7 @@ Codefresh library chart -![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) +![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) ## Installing the Chart @@ -18,7 +18,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g. # Chart.yaml dependencies: - name: cf-common - version: 0.0.9 + version: 0.0.10 repository: https://chartmuseum.codefresh.io/cf-common ``` diff --git a/charts/cf-common/templates/common/_annotations.tpl b/charts/cf-common/templates/common/_annotations.tpl new file mode 100644 index 00000000..1e061130 --- /dev/null +++ b/charts/cf-common/templates/common/_annotations.tpl @@ -0,0 +1,37 @@ +{{/* +Render checksum annotation +Usage: +*/}} +{{- define "cf-common.annotations.podAnnotations" -}} + +{{- if .Values.podAnnotations -}} + {{- include "cf-common.tplrender" (dict "Values" .Values.podAnnotations "context" $) | nindent 0 }} +{{- end -}} + +{{- $configMapFound := dict -}} +{{- range $configMapIndex, $configMapItem := .Values.configMaps -}} + + {{- if $configMapItem.enabled -}} + {{- $_ := set $configMapFound $configMapIndex ( include "cf-common.tplrender" (dict "Values" $configMapItem.data "context" $) | sha256sum) -}} + {{- end -}} + + {{- if $configMapFound -}} + {{- printf "checksum/config: %v" (toYaml $configMapFound | sha256sum) | nindent 0 -}} + {{- end -}} + +{{- end -}} + +{{- $secretFound := dict -}} +{{- range $secretIndex, $secretItem := .Values.secrets -}} + + {{- if $secretItem.enabled -}} + {{- $_ := set $secretFound $secretIndex ( include "cf-common.tplrender" (dict "Values" $secretItem.stringData "context" $) | sha256sum) -}} + {{- end -}} + + {{- if $secretFound -}} + {{- printf "checksum/secret: %v" (toYaml $secretFound | sha256sum) | nindent 0 -}} + {{- end -}} + +{{- end -}} + +{{- end -}} diff --git a/charts/cf-common/templates/controller/_deployment.tpl b/charts/cf-common/templates/controller/_deployment.tpl index b04f40bd..940aaae6 100644 --- a/charts/cf-common/templates/controller/_deployment.tpl +++ b/charts/cf-common/templates/controller/_deployment.tpl @@ -51,9 +51,9 @@ spec: {{- if .Values.podLabels }} {{- include "cf-common.tplrender" (dict "Values" .Values.podLabels "context" $) | nindent 8 }} {{- end }} - {{- if .Values.podAnnotations }} + {{- with include "cf-common.annotations.podAnnotations" . }} annotations: - {{- include "cf-common.tplrender" (dict "Values" .Values.podAnnotations "context" $) | nindent 8 }} + {{- . | nindent 8}} {{- end }} spec: {{- include "cf-common.controller.pod" . | trim | nindent 6 -}} {{- end -}} diff --git a/charts/cf-common/templates/ingress/_ingress.tpl b/charts/cf-common/templates/render/_ingress.tpl similarity index 100% rename from charts/cf-common/templates/ingress/_ingress.tpl rename to charts/cf-common/templates/render/_ingress.tpl