diff --git a/library/common-test/tests/cnpg/cluster_validation_test.yaml b/library/common-test/tests/cnpg/cluster_validation_test.yaml index b38e898b..f8c8ee78 100644 --- a/library/common-test/tests/cnpg/cluster_validation_test.yaml +++ b/library/common-test/tests/cnpg/cluster_validation_test.yaml @@ -25,17 +25,17 @@ tests: - failedTemplate: errorMessage: CNPG - Expected a non-empty [database] key - - it: should fail with invalid version + - it: should fail with invalid pgVersion set: cnpg: my-pg: enabled: true user: test-user database: test-db - version: invalid + pgVersion: invalid asserts: - failedTemplate: - errorMessage: CNPG - Expected [version] to be one of [legacy], but got [invalid] + errorMessage: CNPG - Expected [version] to be one of [15, 16], but got [invalid] - it: should fail with hibernate not a bool set: @@ -71,7 +71,7 @@ tests: type: invalid asserts: - failedTemplate: - errorMessage: CNPG Cluster - Expected [type] to be one of [postgresql, postgis, timescaledb], but got [invalid] + errorMessage: CNPG Cluster - Expected [type] to be one of [postgres, postgis, timescaledb], but got [invalid] - it: should fail with invalid log level set: @@ -181,19 +181,6 @@ tests: - failedTemplate: errorMessage: CNPG - Expected [pgVersion] to be a string, but got [float64] - - it: should fail with invalid pgVersion - set: - cnpg: - my-pg: - enabled: true - user: test-user - database: test-db - mode: standalone - pgVersion: invalid - asserts: - - failedTemplate: - errorMessage: CNPG - Expected [pgVersion] to be one of [15, 16], but got [invalid] - - it: should fail with invalid recovery method set: cnpg: diff --git a/library/common/templates/lib/cnpg/cluster/_validation.tpl b/library/common/templates/lib/cnpg/cluster/_validation.tpl index 80943905..4521f9b9 100644 --- a/library/common/templates/lib/cnpg/cluster/_validation.tpl +++ b/library/common/templates/lib/cnpg/cluster/_validation.tpl @@ -8,7 +8,7 @@ {{- end -}} {{- end -}} - {{- if $objectData.version -}} + {{- 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)) -}}