Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions charts/cf-common-test/tests/deployment/metadata_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion charts/cf-common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions charts/cf-common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
```

Expand Down
37 changes: 37 additions & 0 deletions charts/cf-common/templates/common/_annotations.tpl
Original file line number Diff line number Diff line change
@@ -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 -}}
4 changes: 2 additions & 2 deletions charts/cf-common/templates/controller/_deployment.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}