Skip to content

Commit 23c2590

Browse files
fix(cf-common): reorder image tpl logic (#7)
* bugfix(cf-common): reorder image tpl logic * add tests
1 parent 55562b3 commit 23c2590

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,19 @@ tests:
247247
- equal:
248248
path: spec.template.spec.containers[0].image
249249
value: gcr.io/codefresh-enterprise/codefresh/cf-api:latest
250+
251+
# For backward compatibility (onprem with private docker registry)
252+
- it: Test main container with private docker registry prefix defined in global and local
253+
values:
254+
- values.yaml
255+
set:
256+
global:
257+
privateRegistry: true
258+
dockerRegistry: myregistry.io/
259+
image: codefresh/cf-api
260+
dockerRegistry: gcr.io/codefresh-enterprise/
261+
imageTag: latest
262+
asserts:
263+
- equal:
264+
path: spec.template.spec.containers[0].image
265+
value: myregistry.io/codefresh/cf-api:latest

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

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,6 @@ Usage:
1818
{{- end -}}
1919
{{- end -}}
2020

21-
{{- /*
22-
For backward compatibility (onprem with private docker registry)
23-
*/}}
24-
{{- if $.Values.global -}}
25-
{{- if and $.Values.global.privateRegistry $.Values.global.dockerRegistry -}}
26-
{{ $registryName = $.Values.global.dockerRegistry | trimSuffix "/" }}
27-
{{- end -}}
28-
{{- end -}}
29-
3021
{{- /*
3122
For backward compatibility with legacy var struct
3223
e.g.:
@@ -46,6 +37,15 @@ cf-api:
4637
{{- $imageTag = $.Values.imageTag | toString -}}
4738
{{- end -}}
4839

40+
{{- /*
41+
For backward compatibility (onprem with private docker registry)
42+
*/}}
43+
{{- if $.Values.global -}}
44+
{{- if and $.Values.global.privateRegistry $.Values.global.dockerRegistry -}}
45+
{{ $registryName = $.Values.global.dockerRegistry | trimSuffix "/" }}
46+
{{- end -}}
47+
{{- end -}}
48+
4949
{{- printf "%s/%s:%s" $registryName $repositoryName $imageTag -}}
5050

5151
{{- end -}}

0 commit comments

Comments
 (0)