Skip to content

Commit 55562b3

Browse files
feat(cf-common): upd image.tpl for backward compatibility (#6)
* feat(cf-common): upd image.tpl for backward compatibility * wrap imagePullSecrets in tpl * add tests
1 parent 0b3e6cb commit 55562b3

File tree

6 files changed

+53
-6
lines changed

6 files changed

+53
-6
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,16 @@ tests:
234234
- equal:
235235
path: spec.template.spec.containers[0].image
236236
value: myregistry.io/codefresh/cf-api:master
237+
238+
# For backward compatibility (onprem with private docker registry)
239+
- it: Test main container with legacy var structure for image
240+
values:
241+
- values.yaml
242+
set:
243+
image: codefresh/cf-api
244+
dockerRegistry: gcr.io/codefresh-enterprise/
245+
imageTag: latest
246+
asserts:
247+
- equal:
248+
path: spec.template.spec.containers[0].image
249+
value: gcr.io/codefresh-enterprise/codefresh/cf-api:latest

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,22 @@ tests:
4848
path: spec.template.spec.imagePullSecrets
4949
count: 2
5050

51+
- it: Test deployment TPL imagePullSecrets
52+
release:
53+
name: cf
54+
values:
55+
- values.yaml
56+
set:
57+
global:
58+
pullSecretName: ecr-codefresh
59+
imagePullSecrets:
60+
- "{{ .Release.Name }}-{{ .Values.global.pullSecretName }}-registry"
61+
asserts:
62+
- contains:
63+
path: spec.template.spec.imagePullSecrets
64+
content:
65+
name: cf-ecr-codefresh-registry
66+
5167
- it: Test deployment's initContainer is present and valid
5268
values:
5369
- values.yaml

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ global:
44
- global-pull-secret
55
volumeName: some-existing-volume
66

7-
87
imagePullSecrets:
98
- my-pull-secret
109

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.5
5+
version: 0.0.6
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.5](https://img.shields.io/badge/Version-0.0.5-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.6](https://img.shields.io/badge/Version-0.0.6-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.5
21+
version: 0.0.6
2222
repository: https://chartmuseum.codefresh.io/cf-common
2323
```
2424

charts/cf-common/templates/container/_image.tpl

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,25 @@ For backward compatibility (onprem with private docker registry)
2727
{{- end -}}
2828
{{- end -}}
2929

30+
{{- /*
31+
For backward compatibility with legacy var struct
32+
e.g.:
33+
cf-api:
34+
enabled: true
35+
image: codefresh/cf-api
36+
dockerRegistry: gcr.io/codefresh-enterprise/
37+
imageTag: latest
38+
*/}}
39+
{{- if $.Values.dockerRegistry -}}
40+
{{- $registryName = $.Values.dockerRegistry | trimSuffix "/" -}}
41+
{{- end -}}
42+
{{- if $.Values.image -}}
43+
{{- $repositoryName = $.Values.image -}}
44+
{{- end -}}
45+
{{- if $.Values.imageTag -}}
46+
{{- $imageTag = $.Values.imageTag | toString -}}
47+
{{- end -}}
48+
3049
{{- printf "%s/%s:%s" $registryName $repositoryName $imageTag -}}
3150

3251
{{- end -}}
@@ -46,7 +65,7 @@ Usage:
4665
{{- end -}}
4766

4867
{{- range .Values.global.imagePullSecrets -}}
49-
{{- $pullSecrets = append $pullSecrets . -}}
68+
{{- $pullSecrets = append $pullSecrets (include "cf-common.tplrender" (dict "Values" . "context" $)) -}}
5069
{{- end -}}
5170
{{- end -}}
5271

@@ -56,7 +75,7 @@ Usage:
5675
{{- end -}}
5776

5877
{{- range .Values.imagePullSecrets -}}
59-
{{- $pullSecrets = append $pullSecrets . -}}
78+
{{- $pullSecrets = append $pullSecrets (include "cf-common.tplrender" (dict "Values" . "context" $)) -}}
6079
{{- end -}}
6180
{{- end -}}
6281

0 commit comments

Comments
 (0)