Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow empty string value for config entries #1603

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manifests/server/config_entry.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
15 changes: 15 additions & 0 deletions spec/defines/server/config_entry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,19 @@
.that_notifies('Postgresql::Server::Instance::Service[main]')
end
end

# Example use case for empty values: using transaction-bound session
# variables, like `SET LOCAL awesome_app.tenant_id = 92834` requires the
# variable to be defined in postgresql.conf and initialised with a default
# value (at least for PostgreSQL 13 and older, possibly also in newer
# versions). The default value can, and sometimes, depending on the
# application, should, be empty.
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
Loading