Details
Description
Case and selector match should be recursive. Currently, the match operator only performs a surface level match.
case [green, 2, $whatever] {
|
[/ee/, Integer[0,10], default] : { notice 'yes' }
|
default: { notice 'no' }
|
}
|
The above example should notice 'yes', it currently notices 'no'.
UPDATE
—
Recursive matching means that the same matching rules (as for the surface level) now applies recursively:
- A literal default accepts any value (e.g. [1,2,3] is matched by [1, default, 3] )
- A regexp can match a String value (e.g. "hello world" is matched by /hello .*/)
- A data type can match a value of that type (e.g. 3 matches Integer[1,10])
- Arrays must match in size to match the option
- Hashes match if the keys in the option have an equal key in the tested value, and the option key's value match the tested value.
- Array entries and hash entries (values) are processed recursively.
The relevant section in the specification is: https://github.com/puppetlabs/puppet-specifications/blob/4.0.0/language/expressions.md#case-expression
(note the reference to the tag 4.0.0 as there are additional features in the 4.1.0 version - notably PUP-4193 - lambda support).
risk assessment: medium (manual validate for now)
probability: low
severity: medium (work arounds)
test layer: unit