From 263eaab5a18131747ebbd4e2d7052db91a9d2eed Mon Sep 17 00:00:00 2001 From: Andreas Ntaflos Date: Fri, 5 Jul 2024 16:49:31 +0200 Subject: [PATCH] Allow empty string value for config entries PostgreSQL supports and allows config entries, such as those in postgresql.conf, to be set to the empty string. The `postgresql::server::config_entry` defined type, however, requires String[1] when supplying string values. This doesn't allow for the empty string. This change relaxes the allowed data types for the `value` parameter of `postgresql::server::config_entry` to `String` from `String[1]` and adds a spec test to support the change. Fixes #1602 --- manifests/server/config_entry.pp | 2 +- spec/defines/server/config_entry_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/manifests/server/config_entry.pp b/manifests/server/config_entry.pp index e6460659a2..30142f290b 100644 --- a/manifests/server/config_entry.pp +++ b/manifests/server/config_entry.pp @@ -10,7 +10,7 @@ define postgresql::server::config_entry ( Enum['present', 'absent'] $ensure = 'present', String[1] $key = $name, - Optional[Variant[String[1], Numeric, Array[String[1]]]] $value = undef, + Optional[Variant[String, Numeric, Array[String[1]]]] $value = undef, Stdlib::Absolutepath $path = $postgresql::server::postgresql_conf_path, Optional[String[1]] $comment = undef, String[1] $instance_name = 'main', diff --git a/spec/defines/server/config_entry_spec.rb b/spec/defines/server/config_entry_spec.rb index 243e2ea5e9..d6a279500b 100644 --- a/spec/defines/server/config_entry_spec.rb +++ b/spec/defines/server/config_entry_spec.rb @@ -79,4 +79,13 @@ .that_notifies('Postgresql::Server::Instance::Service[main]') end end + + context 'set a config entry value to the empty string' do + let(:params) { { ensure: 'present', name: 'mydatabase.app_specific_parameter', value: '' } } + + it 'sets value to the empty string' do + expect(subject).to contain_postgresql_conf('mydatabase.app_specific_parameter').with(name: 'mydatabase.app_specific_parameter', + value: '') + end + end end