From 90b41eec3dab171b91d8a9e092e0376a75eb4d6c Mon Sep 17 00:00:00 2001 From: Smyslov Maxim Date: Fri, 27 Feb 2026 15:55:11 +0300 Subject: [PATCH 1/4] copy parca helper Signed-off-by: Smyslov Maxim --- charts/helm_lib/templates/_module_image.tpl | 68 ++++++++++++++------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/charts/helm_lib/templates/_module_image.tpl b/charts/helm_lib/templates/_module_image.tpl index 7485b33..d917a2a 100644 --- a/charts/helm_lib/templates/_module_image.tpl +++ b/charts/helm_lib/templates/_module_image.tpl @@ -1,31 +1,55 @@ {{- /* Usage: {{ include "helm_lib_module_image" (list . "" "(optional)") }} */ -}} {{- /* returns image name */ -}} {{- define "helm_lib_module_image" }} - {{- $context := index . 0 }} {{- /* Template context with .Values, .Chart, etc */ -}} - {{- $containerName := index . 1 | trimAll "\"" }} {{- /* Container name */ -}} - {{- $rawModuleName := $context.Chart.Name }} - {{- if ge (len .) 3 }} - {{- $rawModuleName = (index . 2) }} {{- /* Optional module name */ -}} - {{- end }} - {{- $moduleName := (include "helm_lib_module_camelcase_name" $rawModuleName) }} - {{- $imageDigest := index $context.Values.global.modulesImages.digests $moduleName $containerName }} - {{- if not $imageDigest }} - {{- $error := (printf "Image %s.%s has no digest" $moduleName $containerName ) }} - {{- fail $error }} - {{- end }} - {{- $registryBase := $context.Values.global.modulesImages.registry.base }} - {{- /* handle external modules registry */}} - {{- if index $context.Values $moduleName }} - {{- if index $context.Values $moduleName "registry" }} - {{- if index $context.Values $moduleName "registry" "base" }} - {{- $host := trimAll "/" (index $context.Values $moduleName "registry" "base") }} - {{- $path := trimAll "/" (include "helm_lib_module_kebabcase_name" $rawModuleName) }} - {{- $registryBase = join "/" (list $host $path) }} + {{- $context := index . 0 }} + {{- $containerName := index . 1 | trimAll "\"" }} + + {{- /* New approach: use module package values */}} + {{- if and $context.Module $context.Module.Package }} + {{- $registryBase := $context.Module.Package.Registry.repository }} + {{- if not $registryBase }} + {{- fail "Registry base is not set" }} + {{- end }} + + {{- $packageName := $context.Module.Package.Name }} + {{- if not $packageName }} + {{- fail "Package name is not set" }} + {{- end }} + + {{- $imageDigest := index $context.Module.Package.Digests $containerName }} + {{- if not $imageDigest }} + {{- fail (printf "Image %s has no digest" $containerName) }} + {{- end }} + + {{- printf "%s/%s@%s" $registryBase $packageName $imageDigest }} + + {{- /* Legacy fallback: use global modulesImages values */}} + {{- else }} + {{- $rawModuleName := $context.Chart.Name }} + {{- if ge (len .) 3 }} + {{- $rawModuleName = (index . 2) }} {{- /* Optional module name */ -}} + {{- end }} + {{- $moduleName := (include "helm_lib_module_camelcase_name" $rawModuleName) }} + + {{- $imageDigest := index $context.Values.global.modulesImages.digests $moduleName $containerName }} + {{- if not $imageDigest }} + {{- fail (printf "Image %s.%s has no digest" $moduleName $containerName) }} + {{- end }} + + {{- $registryBase := $context.Values.global.modulesImages.registry.base }} + {{- /* handle external modules registry */}} + {{- if index $context.Values $moduleName }} + {{- if index $context.Values $moduleName "registry" }} + {{- if index $context.Values $moduleName "registry" "base" }} + {{- $host := trimAll "/" (index $context.Values $moduleName "registry" "base") }} + {{- $path := trimAll "/" (include "helm_lib_module_kebabcase_name" $rawModuleName) }} + {{- $registryBase = join "/" (list $host $path) }} + {{- end }} {{- end }} {{- end }} + + {{- printf "%s@%s" $registryBase $imageDigest }} {{- end }} - {{- /* end of external module handling block */}} - {{- printf "%s@%s" $registryBase $imageDigest }} {{- end }} {{- /* Usage: {{ include "helm_lib_module_image_no_fail" (list . "") }} */ -}} From 9933ec5387b0b785bf52c2efdd831a2e7ab57bba Mon Sep 17 00:00:00 2001 From: Smyslov Maxim Date: Fri, 27 Feb 2026 17:28:11 +0300 Subject: [PATCH 2/4] fix Signed-off-by: Smyslov Maxim --- charts/helm_lib/templates/_module_image.tpl | 13 +++--- tests/templates/helm_lib_module_image.yaml | 6 +++ tests/tests/helm_lib_module_image_test.yaml | 44 +++++++++++++++++++++ 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/charts/helm_lib/templates/_module_image.tpl b/charts/helm_lib/templates/_module_image.tpl index d917a2a..74ab354 100644 --- a/charts/helm_lib/templates/_module_image.tpl +++ b/charts/helm_lib/templates/_module_image.tpl @@ -1,10 +1,10 @@ {{- /* Usage: {{ include "helm_lib_module_image" (list . "" "(optional)") }} */ -}} {{- /* returns image name */ -}} {{- define "helm_lib_module_image" }} - {{- $context := index . 0 }} - {{- $containerName := index . 1 | trimAll "\"" }} + {{- $context := index . 0 }} {{- /* Template context with .Values, .Chart, etc */ -}} + {{- $containerName := index . 1 | trimAll "\"" }} {{- /* Container name */ -}} - {{- /* New approach: use module package values */}} + {{- /* New approach: use module package values */}} {{- if and $context.Module $context.Module.Package }} {{- $registryBase := $context.Module.Package.Registry.repository }} {{- if not $registryBase }} @@ -33,11 +33,12 @@ {{- $imageDigest := index $context.Values.global.modulesImages.digests $moduleName $containerName }} {{- if not $imageDigest }} - {{- fail (printf "Image %s.%s has no digest" $moduleName $containerName) }} + {{- $error := (printf "Image %s.%s has no digest" $moduleName $containerName ) }} + {{- fail $error }} {{- end }} {{- $registryBase := $context.Values.global.modulesImages.registry.base }} - {{- /* handle external modules registry */}} + {{- /* handle external modules registry */}} {{- if index $context.Values $moduleName }} {{- if index $context.Values $moduleName "registry" }} {{- if index $context.Values $moduleName "registry" "base" }} @@ -47,7 +48,7 @@ {{- end }} {{- end }} {{- end }} - + {{- /* end of external module handling block */}} {{- printf "%s@%s" $registryBase $imageDigest }} {{- end }} {{- end }} diff --git a/tests/templates/helm_lib_module_image.yaml b/tests/templates/helm_lib_module_image.yaml index d840e64..9bcec02 100644 --- a/tests/templates/helm_lib_module_image.yaml +++ b/tests/templates/helm_lib_module_image.yaml @@ -1,3 +1,4 @@ +# Fallbacked logic embeddedModule: {{ include "helm_lib_module_image" (list . "testContainer") }} embeddedModuleWithOptionalName: {{ include "helm_lib_module_image" (list . "testContainer" "fooBar") }} --- @@ -22,3 +23,8 @@ moduleImageNoFailNotExist: {{ include "helm_lib_module_image_no_fail" (list . "n commonImage: {{ include "helm_lib_module_common_image" (list . "commonContainer") }} commonImageNoFail: {{ include "helm_lib_module_common_image_no_fail" (list . "commonContainer") }} commonImageNoFailNotExist: {{ include "helm_lib_module_common_image_no_fail" (list . "nonExistentCommonContainer") }} +--- +# New approach: use module package values +externalModuleImage: {{ include "helm_lib_module_image" (list .Values.new "testContainer") }} +externalModuleImageWithOptionalName: {{ include "helm_lib_module_image" (list .Values.new "testContainer" "fooBar") }} +externalModuleKebabImageWithOptionalName: {{ include "helm_lib_module_image" (list .Values.new "externalContainer" "some-module") }} diff --git a/tests/tests/helm_lib_module_image_test.yaml b/tests/tests/helm_lib_module_image_test.yaml index 313de51..3bced1a 100644 --- a/tests/tests/helm_lib_module_image_test.yaml +++ b/tests/tests/helm_lib_module_image_test.yaml @@ -2,6 +2,35 @@ suite: helm_lib_module_image definition templates: - helm_lib_module_image.yaml set: + new: + Chart: + Name: test-module + Module: + Package: + Name: "test-module" + Digests: + testContainer: "sha111" + externalContainer: "sha222" + commonContainer: "sha333" + Registry: + name: "deckhouse" + repository: "registry.deckhouse.io/deckhouse/ce" + Version: "1.0.0" + Deckhouse: + modulesImages: + registry: + base: "registry.deckhouse.io/ce/modules/" + digests: + testModule: + testContainer: "sha444" + externalContainer: "sha555" + fooBar: + testContainer: "sha666" + someModule: + externalContainer: "sha777" + common: + commonContainer: "sha888" + global: modulesImages: registry: @@ -17,6 +46,7 @@ set: common: commonContainer: "sha999" tests: + # Fallbacked logic - it: should render embedded module image documentIndex: 0 asserts: @@ -116,3 +146,17 @@ tests: - equal: path: "commonImageNoFailNotExist" value: null + + # New approach: use module package values + - it: should render external module image + documentIndex: 7 + asserts: + - equal: + path: "externalModuleImage" + value: "registry.deckhouse.io/deckhouse/ce/test-module@sha111" + - equal: + path: "externalModuleImageWithOptionalName" + value: "registry.deckhouse.io/deckhouse/ce/test-module@sha111" + - equal: + path: "externalModuleKebabImageWithOptionalName" + value: "registry.deckhouse.io/deckhouse/ce/test-module@sha222" From 8d78a0aa0aa2d859c320597d2bc9e47e7385da39 Mon Sep 17 00:00:00 2001 From: Maxim Smyslov <70270470+riptide-01@users.noreply.github.com> Date: Mon, 2 Mar 2026 11:19:35 +0000 Subject: [PATCH 3/4] bump chart version Signed-off-by: Smyslov Maxim --- charts/helm_lib/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/helm_lib/Chart.yaml b/charts/helm_lib/Chart.yaml index 8e94434..327caf5 100644 --- a/charts/helm_lib/Chart.yaml +++ b/charts/helm_lib/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 type: library name: deckhouse_lib_helm -version: 1.70.3 +version: 1.70.4 description: "Helm utils template definitions for Deckhouse modules." From 8c4d0eedd7b79e60b977adf988736b4651f26e35 Mon Sep 17 00:00:00 2001 From: Smyslov Maxim Date: Tue, 3 Mar 2026 16:38:50 +0300 Subject: [PATCH 4/4] bump Signed-off-by: Smyslov Maxim --- charts/helm_lib/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/helm_lib/Chart.yaml b/charts/helm_lib/Chart.yaml index 327caf5..c0b3b2f 100644 --- a/charts/helm_lib/Chart.yaml +++ b/charts/helm_lib/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 type: library name: deckhouse_lib_helm -version: 1.70.4 +version: 1.71.1 description: "Helm utils template definitions for Deckhouse modules."