-
Notifications
You must be signed in to change notification settings - Fork 611
Allow empty string value for config entries #1603
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
base: main
Are you sure you want to change the base?
Conversation
I don't think I can do anything about the failing tests (labeller and mend). The rest looks good. |
@bastelfreak Will do. Our use case for empty strings here is that we have applications that use transaction-bound session variables, as in PostgreSQL 13 (and possibly newer versions also) requires such session variables to be defined beforehand and initialised with a default value, such as the empty string, in postgresql.conf. |
263eaab
to
6cb0f1f
Compare
So this has been open for a long while now. Any chance to get it merged? |
6cb0f1f
to
34fc7a7
Compare
This is still open, even though approvals were given. What do I need to do to get this merged? Some acceptance tests are failing, but apparently not because of my changes. |
34fc7a7
to
b1dd0c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondered about purging empty entries, but that's done with Undef
:
puppetlabs-postgresql/manifests/server.pp
Lines 220 to 225 in d5911ec
$config_entries.each |$entry, $value| { | |
postgresql::server::config_entry { $entry: | |
ensure => bool2str($value =~ Undef, 'absent', 'present'), | |
value => $value, | |
} | |
} |
@@ -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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the array also allow empty strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not aware of a use-case where an array would contain empty string values.
But I am not even sure if array values make sense for Postgres config entries, because it seems to use just (quoted) strings, integers, floats and booleans (https://www.postgresql.org/docs/current/config-setting.html#CONFIG-SETTING-NAMES-VALUES). And from quickly looking at the postgresql_conf
provider I don't immediately see where/how it even handles array values? But in any case, I don't think we need to touch this part of the functionality here. Just support for single, empty string values would be nice :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, it seems the accepted data types of $value
were changed to include Array[String[1]]
, and the "parsed" provider was replaced by a "ruby" provider, but there doesn't seem to have been any code added to actually handle such array values. The parsed provider had something like h[:value].join(', ')
when h[:value]
was an array, but I see no equivalent in the ruby provider.
But I suppose this discussion is best moved elsewhere, probably to its own bug report?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, it seems the accepted data types of
$value
were changed to includeArray[String[1]]
, and the "parsed" provider was replaced by a "ruby" provider, but there doesn't seem to have been any code added to actually handle such array values. The parsed provider had something likeh[:value].join(', ')
whenh[:value]
was an array, but I see no equivalent in the ruby provider.
If the implementation is h[:value].join(', ')
then an empty array should result in an empty string and allowing empty strings within the array doesn't make sense. It'd result in ,
which is probably never valid. In other words, consider my comments addressed.
But I suppose this discussion is best moved elsewhere, probably to its own bug report?
Yes, agreed.
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 puppetlabs#1602
b1dd0c5
to
e859b1f
Compare
@ekohl Thank you for taking the time to look at and review this! |
CI is busted because Perforce is still using ubuntu-20.04. I think we should wait until they fix that |
Summary
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 ofpostgresql::server::config_entry
toString
fromString[1]
and adds a spec test to support the change.Related Issues (if any)
#1602
Checklist
puppet apply
)