Puppet Function: rspamd::create_config_resources
- Defined in:
- vendor_modules/rspamd/functions/create_config_resources.pp
- Function type:
- Puppet Language
Summary
create rspamd::config resources from a nested hash (e.g. from hiera)Overview
Function: rspamd::create_config_resources()
Create rspamd::config resources from a nested hash, suitable for conveniently loading values from hiera. The key-value pairs from the hash represent config keys and values passed to rspamd::config for simple values, Hash values recursively create nested sections. Arrays that only contain Hash values are created as multi-value keys (or “duplicate sections”), while all other arrays are printed inline (e.g. [a,b,c]).
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'vendor_modules/rspamd/functions/create_config_resources.pp', line 24
function rspamd::create_config_resources(Hash[String, NotUndef] $config_hash, Hash $params={}, Array[String] $sections=[]) {
$config_hash.each |$key, $value| {
case $value {
Hash: {
rspamd::create_config_resources($value, $params, $sections + $key)
}
Array[Hash]: {
$indexed_hash = $value.map |$index, $v| {
{ "${key}[${index}]" => $v }
}.reduce({}) |$a,$b| { $a + $b }
rspamd::create_config_resources($indexed_hash, $params, $sections)
}
default: {
rspamd::config { "${params[file]}:${join($sections + $key, '.')}":
sections => $sections,
key => $key,
value => $value,
* => $params
}
}
}
}
}
|