Puppet Function: bsdauth::flatten_servers

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

Overview

bsdauth::flatten_servers(Array[BSDAuth::LDAP::Server, 1] $servers)Array[String, 1]

Flatten an array of LDAP servers to an array of strings.

Examples:

bsdauth::flatten_servers([{'hostname' => '192.0.2.1'}])

Parameters:

  • servers (Array[BSDAuth::LDAP::Server, 1])

    The array of servers to flatten.

Returns:

  • (Array[String, 1])

    The array of flattened servers.

Since:

  • 2.0.0



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'functions/flatten_servers.pp', line 11

function bsdauth::flatten_servers(Array[BSDAuth::LDAP::Server, 1] $servers) {

  $servers.map |Integer $i, BSDAuth::LDAP::Server $server| {

    $prefix = $i ? {
      0       => 'x-ldap-server',
      default => "x-ldap-serveralt${$i - 1}",
    }

    # Strip off any trailing commas thanks to optional values
    regsubst("${prefix}=${server[hostname]},${server[port]},${server[mode]},${server[version]}", ',+$', '')
  }
}