Puppet Function: role::expand_search_namespaces
- Defined in:
- functions/expand_search_namespaces.pp
- Function type:
- Puppet Language
Summary
Sanitizes Role::SearchNamespaces for use in `role`.Overview
This function is used to sanitize user input and return a single map with namespace - separator entries.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'functions/expand_search_namespaces.pp', line 18
function role::expand_search_namespaces(
String $separator,
Variant[Role::SearchNamespace, Array[Role::SearchNamespace]] $search,
) >> Hash[String, String] {
$namespaces = [$search].flatten.unique.reduce({}) |Hash[String, String] $memo, Role::SearchNamespace $space| {
if $space =~ String {
$memo + { $space => $separator }
}
else {
$memo + $space.reduce({}) |Hash[String, String] $spaces, Tuple $kv| {
$key = $kv[0]
$value = $kv[1]
$_value = $value ? {
undef => $separator,
default => $value,
}
$memo + { $key => $_value }
}
}
}
}
|