Puppet Function: sendmail::canonify_array
- Defined in:
- functions/canonify_array.pp
- Function type:
- Puppet Language
Summary
Canonify an arrayOverview
Rewrite the input array the following way:
-
strip spaces from the beginning and end of each string
-
remove duplicate entries
-
sort the result
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'functions/canonify_array.pp', line 13
function sendmail::canonify_array(Array[String] $arg) >> Array[String] {
# strip items and set to undef if empty
$sparse_array = Array($arg).map |$item| {
$stripped_item = strip($item)
empty($stripped_item) ? {
true => undef,
default => $stripped_item,
}
}
# remove empty items from array
$filtered_array = $sparse_array.filter |$item| { !empty($item) }
# sort result and filter duplicates
unique(sort($filtered_array))
}
|