diff --git a/library/common/templates/class/cnpg/_cluster.tpl b/library/common/templates/class/cnpg/_cluster.tpl index f2d487a9..7d0a58bf 100644 --- a/library/common/templates/class/cnpg/_cluster.tpl +++ b/library/common/templates/class/cnpg/_cluster.tpl @@ -139,13 +139,9 @@ {{- if eq $imageType "Postgres" -}} {{- $imageType = "" -}} {{- end -}} - {{- $pgVersion := $rootCtx.Values.global.fallbackDefaults.pgVersion -}} - {{- with $objectData.pgVersion -}} - {{- $pgVersion = . -}} - {{- end -}} {{/* Format is [postgresCustomNameVersionImage] */}} - {{- $imageKey := printf "postgres%s%sImage" $imageType $pgVersion -}} + {{- $imageKey := printf "postgres%s%sImage" $imageType $objectData.pgVersion -}} {{- $imageValue := fromJson (include "tc.v1.common.lib.container.imageSelector" (dict "rootCtx" $rootCtx "objectData" (dict "imageSelector" $imageKey))) -}} {{- $formatImage := printf "%s:%s" $imageValue.repository $imageValue.tag -}} diff --git a/library/common/templates/lib/cnpg/cluster/_validation.tpl b/library/common/templates/lib/cnpg/cluster/_validation.tpl index 4521f9b9..833f97bd 100644 --- a/library/common/templates/lib/cnpg/cluster/_validation.tpl +++ b/library/common/templates/lib/cnpg/cluster/_validation.tpl @@ -8,16 +8,15 @@ {{- end -}} {{- end -}} - {{- if (hasKey $objectData "version") -}} - {{- if not (kindIs "string" $objectData.pgVersion) -}} - {{/* We must ensure that this is a string, as it is used in image selector that require a string */}} - {{- fail (printf "CNPG - Expected [pgVersion] to be a string, but got [%s]" (kindOf $objectData.pgVersion)) -}} - {{- end -}} + {{/* Kinda imposibble to happen, as we explicitly set it to string on the spawner */}} + {{- if not (kindIs "string" $objectData.pgVersion) -}} + {{/* We must ensure that this is a string, as it is used in image selector that require a string */}} + {{- fail (printf "CNPG - Expected [pgVersion] to be a string, but got [%s]" (kindOf $objectData.pgVersion)) -}} + {{- end -}} - {{- $validVersions := (list "15" "16") -}} - {{- if not (mustHas $objectData.pgVersion $validVersions) -}} - {{- fail (printf "CNPG - Expected [pgVersion] to be one of [%s], but got [%s]" (join ", " $validVersions) $objectData.pgVersion) -}} - {{- end -}} + {{- $validVersions := (list "15" "16") -}} + {{- if not (mustHas $objectData.pgVersion $validVersions) -}} + {{- fail (printf "CNPG - Expected [pgVersion] to be one of [%s], but got [%s]" (join ", " $validVersions) $objectData.pgVersion) -}} {{- end -}} {{- if (hasKey $objectData "hibernate") -}}