Hi,
I've been slowly converting old 3.x codebase (which has seen days of 0.24...) to 4.x and there is a lot of following pattern used for hashes:'
$hash = {
"some" => "defaults"
}
if $thing_one == "is_true" {
$hash["option1"] = $thing_one,
}
if $thing_two == "is_something" {
$hash["option2"] = "something"
}
else {
$hash["option2"] = "something else"
}
etc. Now with immutable hashes I'm forced either to do:'
$hash1 = {
"some" => "defaults"
}
if $thing_one == "is_true" {
$hash2 = {
"option1" => $thing_one,
}
}
else { $hash2 = {} }
if $thing_two == "is_something" {
$hash3 = {
"option2" => "something"
}
}
else {
$hash3 = {
"option2" => "something else"
}
$hash4 = merge($hash1, $hash2, $hash3, $hash3)
or go the hacky route and go to erb and back to use ruby language to do it.
Am I missing something here ? is there a better way to do it? We have a lot of "get a hash, munge it, feed it to either puppet resource or to external config" pattern used in the code and immutability so far doesn't seem like a very useful property