File tree Expand file tree Collapse file tree 6 files changed +124
-14
lines changed
cf-common-test/tests/deployment Expand file tree Collapse file tree 6 files changed +124
-14
lines changed Original file line number Diff line number Diff line change @@ -41,3 +41,84 @@ tests:
4141 asserts :
4242 - failedTemplate :
4343 errorMessage : " something is invalid volume type for volume my-volume!"
44+
45+ - it : Test volumes and volumeMounts from global
46+ values :
47+ - values.yaml
48+ set :
49+ global :
50+ volumes :
51+ global-ca-cert :
52+ enabled : true
53+ type : secret
54+ existingName : my-global-ca-cert-secret
55+ optional : true
56+ container :
57+ volumeMounts :
58+ global-ca-cert :
59+ path :
60+ - mountPath : /etc/ssl/ca.pem
61+ subPath : ca.pem
62+ readOnly : true
63+ asserts :
64+ - contains :
65+ path : spec.template.spec.volumes
66+ content :
67+ name : global-ca-cert
68+ secret :
69+ secretName : my-global-ca-cert-secret
70+ optional : true
71+ - contains :
72+ path : spec.template.spec.containers[0].volumeMounts
73+ content :
74+ name : global-ca-cert
75+ mountPath : /etc/ssl/ca.pem
76+ subPath : ca.pem
77+ readOnly : true
78+
79+ - it : Test merge volumes and volumeMounts with global
80+ values :
81+ - values.yaml
82+ set :
83+ global :
84+ volumes :
85+ ca-cert :
86+ enabled : true
87+ type : secret
88+ existingName : GLOBAL-ca-cert-secret
89+ optional : true
90+ container :
91+ volumeMounts :
92+ ca-cert :
93+ path :
94+ - mountPath : /etc/ssl/global/ca.pem
95+ subPath : ca.pem
96+ readOnly : true
97+ volumes :
98+ ca-cert :
99+ enabled : true
100+ type : secret
101+ existingName : DEFAULT-ca-cert-secret
102+ optional : true
103+ container :
104+ volumeMounts :
105+ ca-cert :
106+ path :
107+ - mountPath : /etc/ssl/default/ca.pem
108+ subPath : ca.pem
109+ readOnly : true
110+ asserts :
111+ - contains :
112+ path : spec.template.spec.volumes
113+ content :
114+ name : ca-cert
115+ secret :
116+ secretName : DEFAULT-ca-cert-secret
117+ optional : true
118+ - contains :
119+ path : spec.template.spec.containers[0].volumeMounts
120+ content :
121+ name : ca-cert
122+ mountPath : /etc/ssl/default/ca.pem
123+ subPath : ca.pem
124+ readOnly : true
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ apiVersion: v2
22appVersion : v0.0.0
33description : Codefresh library chart
44name : cf-common
5- version : 0.0.21
5+ version : 0.0.22
66type : library
77keywords :
88 - codefresh
Original file line number Diff line number Diff line change 22
33Codefresh library chart
44
5- ![ Version: 0.0.21 ] ( https://img.shields.io/badge/Version-0.0.21 -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.22 ] ( https://img.shields.io/badge/Version-0.0.22 -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
1919dependencies :
2020- name : cf-common
21- version : 0.0.21
21+ version : 0.0.22
2222 repository : https://chartmuseum.codefresh.io/cf-common
2323` ` `
2424
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ For backward compatibility (.Values.env takes precedence over .Values.container.
7373
7474 { {- with .Values.volumeMounts } }
7575 volumeMounts:
76- { {- include " cf-common.volumeMounts" . | trim | nindent 2 } }
76+ { {- include " cf-common.volumeMounts" (dict " Values " . " context " $) | trim | nindent 2 } }
7777 { {- end } }
7878
7979 { {- with .Values.probes } }
Original file line number Diff line number Diff line change @@ -3,13 +3,30 @@ Renders volumeMounts list in container
33Usage:
44 {{- with .Values.volumeMounts } }
55 volumeMounts:
6- { {- include " cf-common.volumeMounts" . | trim | nindent 2 } }
6+ { {- include " cf-common.volumeMounts" (dict " Values " . " context " $) | trim | nindent 2 } }
77 { {- end } }
88*/}}
99
1010{ {- define " cf-common.volumeMounts" -} }
11+ { {/* Restoring root $ context */} }
12+ { {- $ := .context -} }
1113
12- { {- range $mountIndex , $mountItem := . } }
14+ { {- $defaultVolumeMounts := dict -} }
15+ { {- $globalVolumeMounts := dict -} }
16+
17+ { {- if .Values -} }
18+ { {- $defaultVolumeMounts = deepCopy .Values -} }
19+ { {- end -} }
20+ { {- if $.Values.global -} }
21+ { {- if $.Values.global.container -} }
22+ { {- if $.Values.global.container.volumeMounts -} }
23+ { {- $globalVolumeMounts = deepCopy $.Values.global.container.volumeMounts -} }
24+ { {- end -} }
25+ { {- end -} }
26+ { {- end -} }
27+ { {- $mergedVolumeMounts := mergeOverwrite $globalVolumeMounts $defaultVolumeMounts -} }
28+
29+ { {- range $mountIndex , $mountItem := $mergedVolumeMounts } }
1330
1431{ {- if not (kindIs " slice" $mountItem .path) } }
1532 { { fail (printf " ERROR: volumeMounts.%s.path block must be a list!" $mountIndex ) } }
Original file line number Diff line number Diff line change 11{ {/*
22Renders volumes in controller template
3-
43Usage:
5- volumes:
6- {{ include " cf-common.volumes" (dict " Values" .Values.volumes " context" $) } }
7- { { include " cf-common.volumes" (dict " Values" .Values.existingVolumes " context" $) } }
4+ {{- with .Values.volumes } }
5+ volumes:
6+ { { include " cf-common.volumes" (dict " Values" . " context" $) | trim } }
7+ { {- end } }
88*/}}
99
10- { {- define " cf-common.volumes" } }
11-
10+ { {- define " cf-common.volumes" -} }
1211{ {/* Restoring root $ context */} }
1312{ {- $ := .context -} }
1413
15- { {- range $volumeIndex , $volumeItem := .Values } }
14+ { {- $defaultVolumes := dict -} }
15+ { {- $globalVolumes := dict -} }
16+
17+ { {- if .Values -} }
18+ { {- $defaultVolumes = deepCopy .Values -} }
19+ { {- end -} }
20+ { {- if $.Values.global -} }
21+ { {- if $.Values.global.volumes -} }
22+ { {- $globalVolumes = deepCopy $.Values.global.volumes -} }
23+ { {- end -} }
24+ { {- end -} }
25+ { {- $mergedVolumes := mergeOverwrite $globalVolumes $defaultVolumes -} }
26+
27+ { {- range $volumeIndex , $volumeItem := $mergedVolumes } }
1628
1729{ {- if $volumeItem .enabled } }
1830- name: { { $volumeIndex } }
@@ -53,4 +65,4 @@ volumes:
5365
5466{ {- end } }
5567
56- { {- end } }
68+ { {- end - } }
You can’t perform that action at this time.
0 commit comments