Skip to content

Commit 58d5771

Browse files
authored
Revert "In the helm_lib_module_image helper, we need to insert the lowerCamelCase module name (#142)" (#149)
This reverts commit ab830b4. Signed-off-by: Pavel Okhlopkov <[email protected]>
1 parent fcde50c commit 58d5771

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

charts/helm_lib/templates/_module_image.tpl

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
{{- if index $context.Values $moduleName "registry" }}
2020
{{- if index $context.Values $moduleName "registry" "base" }}
2121
{{- $host := trimAll "/" (index $context.Values $moduleName "registry" "base") }}
22-
{{- $path := trimAll "/" $moduleName }}
22+
{{- $path := trimAll "/" (include "helm_lib_module_kebabcase_name" $rawModuleName) }}
2323
{{- $registryBase = join "/" (list $host $path) }}
2424
{{- end }}
2525
{{- end }}
@@ -33,19 +33,18 @@
3333
{{- define "helm_lib_module_image_no_fail" }}
3434
{{- $context := index . 0 }} {{- /* Template context with .Values, .Chart, etc */ -}}
3535
{{- $containerName := index . 1 | trimAll "\"" }} {{- /* Container name */ -}}
36-
{{- $rawModuleName := $context.Chart.Name }}
36+
{{- $moduleName := (include "helm_lib_module_camelcase_name" $context) }}
3737
{{- if ge (len .) 3 }}
38-
{{- $rawModuleName = (index . 2) }} {{- /* Optional module name */ -}}
38+
{{- $moduleName = (include "helm_lib_module_camelcase_name" (index . 2)) }} {{- /* Optional module name */ -}}
3939
{{- end }}
40-
{{- $moduleName := (include "helm_lib_module_camelcase_name" $rawModuleName) }}
4140
{{- $imageDigest := index $context.Values.global.modulesImages.digests $moduleName $containerName }}
4241
{{- if $imageDigest }}
4342
{{- $registryBase := $context.Values.global.modulesImages.registry.base }}
4443
{{- if index $context.Values $moduleName }}
4544
{{- if index $context.Values $moduleName "registry" }}
4645
{{- if index $context.Values $moduleName "registry" "base" }}
4746
{{- $host := trimAll "/" (index $context.Values $moduleName "registry" "base") }}
48-
{{- $path := trimAll "/" $moduleName }}
47+
{{- $path := trimAll "/" $context.Chart.Name }}
4948
{{- $registryBase = join "/" (list $host $path) }}
5049
{{- end }}
5150
{{- end }}
@@ -102,12 +101,11 @@
102101
{{- define "helm_lib_module_image_digest_no_fail" }}
103102
{{- $context := index . 0 }} {{- /* Template context with .Values, .Chart, etc */ -}}
104103
{{- $containerName := index . 1 | trimAll "\"" }} {{- /* Container name */ -}}
105-
{{- $rawModuleName := $context.Chart.Name }}
104+
{{- $moduleName := (include "helm_lib_module_camelcase_name" $context) }}
106105
{{- if ge (len .) 3 }}
107-
{{- $rawModuleName = (index . 2) }} {{- /* Optional module name */ -}}
106+
{{- $moduleName = (include "helm_lib_module_camelcase_name" (index . 2)) }} {{- /* Optional module name */ -}}
108107
{{- end }}
109-
{{- $moduleName := (include "helm_lib_module_camelcase_name" $rawModuleName) }}
110108
{{- $moduleMap := index $context.Values.global.modulesImages.digests $moduleName | default dict }}
111109
{{- $imageDigest := index $moduleMap $containerName | default "" }}
112110
{{- printf "%s" $imageDigest }}
113-
{{- end }}
111+
{{- end }}

tests/tests/helm_lib_module_image_test.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ tests:
3939
asserts:
4040
- equal:
4141
path: "externalModuleImage"
42-
value: "registry.deckhouse.io/modules/testModule@sha321"
42+
value: "registry.deckhouse.io/modules/test-module@sha321"
4343
- equal:
4444
path: "externalModuleImageWithOptionalName"
45-
value: "registry.flant.com/modules/someModule@sha543"
45+
value: "registry.flant.com/modules/some-module@sha543"
4646
- equal:
4747
path: "externalModuleKebabImageWithOptionalName"
48-
value: "registry.flant.com/modules/someModule@sha543"
48+
value: "registry.flant.com/modules/some-module@sha543"
4949

5050
- it: should render external module image with trail slash
5151
documentIndex: 1
@@ -59,7 +59,7 @@ tests:
5959
asserts:
6060
- equal:
6161
path: "externalModuleImage"
62-
value: "registry.deckhouse.io/modules/testModule@sha321"
62+
value: "registry.deckhouse.io/modules/test-module@sha321"
6363

6464
- it: should render external module image digest
6565
documentIndex: 2
@@ -115,4 +115,4 @@ tests:
115115
value: "registry.deckhouse.io/deckhouse/ce@sha999"
116116
- equal:
117117
path: "commonImageNoFailNotExist"
118-
value: null
118+
value: null

0 commit comments

Comments
 (0)