Details
Description
Hi everyone,
I'm not sure whether this is a Puppet or a Hiera issue, so if I'm wrong here just tell me or move the issue around .
Assuming the following construction:
class foo ( |
Optional[String[1]] $myval = 'something', |
) {
|
[... doesn't matter ...]
|
}
|
Using Hiera, Puppet does an automatic parameter lookup for class variables.
This is working great for "usual" Strings, Integers, Booleans, ... but partially breaks for undef/NULL. To specify "breaks": it looks like as if parameter is assigned a undef/NULL value, it is entirely omitted and not passed to Puppet at all, which leads to the default values.
To demonstrate this:
Hiera with a yaml backend:
foo::myval: 'some string'
|
# $myval == 'some string' (as expected and desired)
|
|
foo::myval: ''
|
# evaluation fails (as expected and desired)
|
|
foo::myval: 3
|
# evaluation fails (as expected and desired)
|
|
foo::myval: NULL
|
# $myval == 'something' (!!! this is the default value and NOT undef as it should be !!!)
|
I consider this to be a bug as assigning a undef/NULL value to a hash-key is working fine:
class foo ( |
Struct[{
|
myval => Optional[String[1]],
|
}] $myhash = { |
myval => 'foo', |
},
|
) {
|
[... doesn't matter ...]
|
}
|
foo::myhash:
|
myval: 'some string'
|
# $myhash['myval'] == 'some string' (as expected and desired)
|
|
foo::myhash:
|
myval: ''
|
# evaluation fails (as expected and desired)
|
|
foo::myhash:
|
myval: 3
|
# evaluation fails (as expected and desired)
|
|
foo::myhash: NULL
|
# $myhash['myval'] == 'foo' (!!! this is the default value and NOT undef as it should be (or actually it should be throwing an error as the key doesn't exist) !!!)
|
|
foo::myhash:
|
myval: NULL
|
# $myhash['myval'] is undef (!!! as expected and desired !!!)
|
Attachments
Issue Links
- relates to
-
PUP-5925 Optional data type and data binding with undef as default value
-
- Closed
-