diff --git a/library/common-test/tests/cnpg/backup_provider_secret_spec_test.yaml b/library/common-test/tests/cnpg/backup_provider_secret_spec_test.yaml index 275ae0f6..9a5286ab 100644 --- a/library/common-test/tests/cnpg/backup_provider_secret_spec_test.yaml +++ b/library/common-test/tests/cnpg/backup_provider_secret_spec_test.yaml @@ -23,7 +23,7 @@ tests: manualBackups: - name: today asserts: - - documentIndex: &secretDoc 3 + - documentIndex: &secretDoc 2 isKind: of: Secret - documentIndex: *secretDoc diff --git a/library/common-test/tests/cnpg/cluster_backup_spec_test.yaml b/library/common-test/tests/cnpg/cluster_backup_spec_test.yaml index 1dc71f84..252c637f 100644 --- a/library/common-test/tests/cnpg/cluster_backup_spec_test.yaml +++ b/library/common-test/tests/cnpg/cluster_backup_spec_test.yaml @@ -21,7 +21,7 @@ tests: azure: connectionString: some-connection-string asserts: - - documentIndex: &secretDoc 2 + - documentIndex: &secretDoc 1 isKind: of: Secret - documentIndex: *secretDoc @@ -97,7 +97,7 @@ tests: google: applicationCredentials: some-credentials asserts: - - documentIndex: &secretDoc 2 + - documentIndex: *secretDoc isKind: of: Secret - documentIndex: *secretDoc @@ -164,7 +164,7 @@ tests: accessKey: some-access-key secretKey: some-secret-key asserts: - - documentIndex: &secretDoc 2 + - documentIndex: *secretDoc isKind: of: Secret - documentIndex: *secretDoc @@ -235,7 +235,7 @@ tests: accessKey: some-access-key secretKey: some-secret-key asserts: - - documentIndex: &secretDoc 2 + - documentIndex: *secretDoc isKind: of: Secret - documentIndex: *secretDoc @@ -306,7 +306,7 @@ tests: accessKey: some-access-key secretKey: some-secret-key asserts: - - documentIndex: &secretDoc 2 + - documentIndex: *secretDoc isKind: of: Secret - documentIndex: *secretDoc @@ -378,7 +378,7 @@ tests: accessKey: some-access-key secretKey: some-secret-key asserts: - - documentIndex: &secretDoc 2 + - documentIndex: *secretDoc isKind: of: Secret - documentIndex: *secretDoc @@ -456,5 +456,5 @@ tests: path: metadata.name value: test-release-name-common-test-cnpg-my-pg - documentIndex: *clusterDoc - isNull: + notExists: path: spec.backup.target diff --git a/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml b/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml index 07df5deb..faa090ac 100644 --- a/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml +++ b/library/common-test/tests/cnpg/cluster_recovery_spec_test.yaml @@ -88,7 +88,7 @@ tests: pitrTarget: time: "2021-01-01T00:00:00Z" asserts: - - documentIndex: &secretDoc 2 + - documentIndex: &secretDoc 1 isKind: of: Secret - documentIndex: *secretDoc diff --git a/library/common-test/tests/cnpg/cluster_spec_test.yaml b/library/common-test/tests/cnpg/cluster_spec_test.yaml index 53f09c22..0eadf682 100644 --- a/library/common-test/tests/cnpg/cluster_spec_test.yaml +++ b/library/common-test/tests/cnpg/cluster_spec_test.yaml @@ -72,7 +72,7 @@ tests: tag: "15.6" global: fallbackDefaults: - pgVersion: "15" + pgVersion: 15 vctAccessModes: - ReadWriteMany - ReadWriteOnce @@ -124,7 +124,7 @@ tests: enabled: true user: test-user database: test-db - pgVersion: "15" + pgVersion: 15 type: vectors asserts: - documentIndex: *clusterDoc @@ -152,7 +152,7 @@ tests: enabled: true user: test-user database: test-db - pgVersion: "15" + pgVersion: 15 asserts: - documentIndex: *clusterDoc isKind: diff --git a/library/common-test/tests/cnpg/credentials_test.yaml b/library/common-test/tests/cnpg/credentials_test.yaml index 826a32b7..77fb7e0f 100644 --- a/library/common-test/tests/cnpg/credentials_test.yaml +++ b/library/common-test/tests/cnpg/credentials_test.yaml @@ -13,7 +13,7 @@ tests: user: test-user database: test-db asserts: - - documentIndex: &secretDoc 3 + - documentIndex: &secretDoc 2 isKind: of: Secret - documentIndex: *secretDoc @@ -36,7 +36,7 @@ tests: path: stringData.password pattern: ^[a-zA-Z0-9]{62}$ - - documentIndex: &secretDoc 2 + - documentIndex: &secretDoc 1 isKind: of: Secret - documentIndex: *secretDoc @@ -73,7 +73,7 @@ tests: enabled: true createRO: false asserts: - - documentIndex: &secretDoc 3 + - documentIndex: &secretDoc 2 isKind: of: Secret - documentIndex: *secretDoc @@ -110,7 +110,7 @@ tests: enabled: true createRO: true asserts: - - documentIndex: &secretDoc 4 + - documentIndex: &secretDoc 3 isKind: of: Secret - documentIndex: *secretDoc @@ -156,7 +156,7 @@ tests: database: test-db password: test-password asserts: - - documentIndex: &secretDoc 3 + - documentIndex: &secretDoc 2 isKind: of: Secret - documentIndex: *secretDoc diff --git a/library/common-test/tests/cnpg/db_wait_test.yaml b/library/common-test/tests/cnpg/db_wait_test.yaml index 499df3e8..a3c93edd 100644 --- a/library/common-test/tests/cnpg/db_wait_test.yaml +++ b/library/common-test/tests/cnpg/db_wait_test.yaml @@ -22,7 +22,7 @@ tests: user: test-user database: test-db asserts: - - documentIndex: &deployDoc 4 + - documentIndex: &deployDoc 3 isKind: of: Deployment - documentIndex: *deployDoc @@ -63,7 +63,7 @@ tests: enabled: true createRO: false asserts: - - documentIndex: &deployDoc 5 + - documentIndex: &deployDoc 4 isKind: of: Deployment - documentIndex: *deployDoc @@ -111,7 +111,7 @@ tests: enabled: true createRO: true asserts: - - documentIndex: &deployDoc 6 + - documentIndex: &deployDoc 5 isKind: of: Deployment - documentIndex: *deployDoc diff --git a/library/common-test/tests/cnpg/pg_version_configmap_test.yaml b/library/common-test/tests/cnpg/pg_version_configmap_test.yaml deleted file mode 100644 index e3262943..00000000 --- a/library/common-test/tests/cnpg/pg_version_configmap_test.yaml +++ /dev/null @@ -1,105 +0,0 @@ -suite: cnpg pgVersion configmap test -templates: - - common.yaml -release: - name: test-release-name - namespace: test-release-namespace -tests: - - it: should generate correct configmap - set: - cnpg: - my-pg: - enabled: true - user: test-user - database: test-db - asserts: - - documentIndex: &cmDoc 1 - isKind: - of: ConfigMap - - documentIndex: *cmDoc - isAPIVersion: - of: v1 - - documentIndex: *cmDoc - equal: - path: metadata.name - value: test-release-name-common-test-cnpg-my-pg-pgversion - - documentIndex: *cmDoc - equal: - path: data.version - value: "16" - - - it: should generate correct configmap with changed defaults - set: - global: - fallbackDefaults: - pgVersion: "15" - cnpg: - my-pg: - enabled: true - user: test-user - database: test-db - asserts: - - documentIndex: *cmDoc - isKind: - of: ConfigMap - - documentIndex: *cmDoc - isAPIVersion: - of: v1 - - documentIndex: *cmDoc - equal: - path: metadata.name - value: test-release-name-common-test-cnpg-my-pg-pgversion - - documentIndex: *cmDoc - equal: - path: data.version - value: "15" - - - it: should generate correct configmap with defaults being a number instead of string - set: - global: - fallbackDefaults: - pgVersion: 15 - cnpg: - my-pg: - enabled: true - user: test-user - database: test-db - asserts: - - documentIndex: *cmDoc - isKind: - of: ConfigMap - - documentIndex: *cmDoc - isAPIVersion: - of: v1 - - documentIndex: *cmDoc - equal: - path: metadata.name - value: test-release-name-common-test-cnpg-my-pg-pgversion - - documentIndex: *cmDoc - equal: - path: data.version - value: "15" - - - it: should generate correct configmap with changed at cnpg level - set: - cnpg: - my-pg: - enabled: true - user: test-user - database: test-db - pgVersion: "15" - asserts: - - documentIndex: *cmDoc - isKind: - of: ConfigMap - - documentIndex: *cmDoc - isAPIVersion: - of: v1 - - documentIndex: *cmDoc - equal: - path: metadata.name - value: test-release-name-common-test-cnpg-my-pg-pgversion - - documentIndex: *cmDoc - equal: - path: data.version - value: "15" diff --git a/library/common-test/tests/container/resources_test.yaml b/library/common-test/tests/container/resources_test.yaml index 8c237c36..e5408941 100644 --- a/library/common-test/tests/container/resources_test.yaml +++ b/library/common-test/tests/container/resources_test.yaml @@ -455,7 +455,7 @@ tests: requests: cpu: 10m memory: 50Mi - - documentIndex: &deploymentDoc 9 + - documentIndex: &deploymentDoc 8 isKind: of: Deployment - documentIndex: *deploymentDoc diff --git a/library/common/templates/addons/vpn/_gluetunContainer.tpl b/library/common/templates/addons/vpn/_gluetunContainer.tpl index 6eb3dc07..a8a1d1fb 100644 --- a/library/common/templates/addons/vpn/_gluetunContainer.tpl +++ b/library/common/templates/addons/vpn/_gluetunContainer.tpl @@ -37,16 +37,21 @@ env: DNS_KEEP_NAMESERVER: "on" DOT: "off" {{- if $.Values.addons.vpn.killSwitch }} -{{- $excludednetworks := ( printf "%v,%v" $.Values.chartContext.podCIDR $.Values.chartContext.svcCIDR ) -}} +{{- $excludednetworks := (printf "%v,%v" $.Values.chartContext.podCIDR $.Values.chartContext.svcCIDR) -}} {{- range $.Values.addons.vpn.excludedNetworks_IPv4 -}} - {{- $excludednetworks = ( printf "%v,%v" $excludednetworks . ) -}} + {{- $excludednetworks = (printf "%v,%v" $excludednetworks .) -}} {{- end }} {{- range $.Values.addons.vpn.excludedNetworks_IPv6 -}} - {{- $excludednetworksv6 = ( printf "%v,%v" $excludednetworks . ) -}} + {{- $excludednetworksv6 = (printf "%v,%v" $excludednetworks .) -}} {{- end }} FIREWALL: "on" FIREWALL_OUTBOUND_SUBNETS: {{ $excludednetworks | quote }} -{{- $inputPorts := (list $.Values.service.main.ports.main.port) -}} +{{- $inputPorts := list -}} +{{- if and + $.Values.service $.Values.service.main $.Values.service.main.ports + $.Values.service.main.ports.main $.Values.service.main.ports.main.port -}} + {{- $inputPorts = list $.Values.service.main.ports.main.port -}} +{{- end -}} {{- $inputPorts = concat $inputPorts $.Values.addons.vpn.inputPorts | mustUniq }} FIREWALL_INPUT_PORTS: {{ join "," $inputPorts }} {{- else }} diff --git a/library/common/templates/spawner/_cnpg.tpl b/library/common/templates/spawner/_cnpg.tpl index 0fe5764f..80df3955 100644 --- a/library/common/templates/spawner/_cnpg.tpl +++ b/library/common/templates/spawner/_cnpg.tpl @@ -24,10 +24,10 @@ {{- if eq $enabled "true" -}} {{/* Handle version string */}} - {{- $pgVersion := $objectData.pgVersion | default (toString $.Values.global.fallbackDefaults.pgVersion) -}} + {{- $pgVersion := ($objectData.pgVersion | default $.Values.global.fallbackDefaults.pgVersion) | toString -}} {{/* Set the updated pgVersion version to objectData */}} - {{- $_ := set $objectData "pgVersion" ($pgVersion | toString) -}} + {{- $_ := set $objectData "pgVersion" $pgVersion -}} {{/* allow for injecting major upgrade code */}} {{- if $objectData.upgradeMajor -}}