Puppet Function: openldap::flatten_access

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

Overview

openldap::flatten_access(Optional[Array[OpenLDAP::Access, 1]] $values)Optional[Array[String, 1]]

Flatten an array of ACL directives to an array of strings.

Examples:

openldap::flatten_access([[{'dn' => '*'}, [{'who' => ['*'], 'access' => 'none'}]]])

Parameters:

  • values (Optional[Array[OpenLDAP::Access, 1]])

    The array of ACL directives to flatten, undef is passed through.

Returns:

  • (Optional[Array[String, 1]])

    The array of flattened strings.

Since:

  • 2.0.0



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'functions/flatten_access.pp', line 11

function openldap::flatten_access(Optional[Array[OpenLDAP::Access, 1]] $values) {

  $values ? {
    undef   => undef,
    default => $values.map |OpenLDAP::Access $value| {
      join([
        'to',
        join(delete_undef_values([
          $value[0]['dn'] ? {
            undef   => undef,
            default => $value[0]['dn'],
          },
          $value[0]['filter'] ? {
            undef   => undef,
            default => "filter=${value[0]['filter']}",
          },
          type($value[0]['attrs']) ? {
            Type[Scalar] => "attrs=${value[0]['attrs']}",
            Type[Array]  => "attrs=${join($value[0]['attrs'], ',')}",
            default      => undef,
          },
        ]), ' '),
        join($value[1].map |OpenLDAP::Access::By $x| {
          join(delete_undef_values([
            'by',
            join($x['who'], ' '),
            $x['access'] ? {
              undef   => undef,
              default => $x['access'],
            },
            $x['control'] ? {
              undef   => undef,
              default => $x['control'],
            },
          ]), ' ')
        }, ' '),
      ], ' ')
    }
  }
}