Puppet Function: role::expand_search_namespaces

Defined in:
functions/expand_search_namespaces.pp
Function type:
Puppet Language

Overview

role::expand_search_namespaces(String $separator, Variant[Role::SearchNamespace, Array[Role::SearchNamespace]] $search)Hash[String, String]

Parameters:

  • separator (String)
  • search (Variant[Role::SearchNamespace, Array[Role::SearchNamespace]])

Returns:

  • (Hash[String, String])


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'functions/expand_search_namespaces.pp', line 1

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 }
      }
    }
  }
}