Puppet Function: postfix::flatten_host

Defined in:
vendor_modules/postfix/functions/flatten_host.pp
Function type:
Puppet Language

Overview

postfix::flatten_host(Optional[Variant[Postfix::Type::Lookup::LDAP::Host, Postfix::Type::Lookup::MySQL::Host, Postfix::Type::Lookup::PgSQL::Host, Postfix::Type::Lookup::Memcache::Host]] $host)Optional[String]

Flatten a host structure to a string.

Examples:

postfix::flatten_host('2001:db8::1')
postfix::flatten_host(['192.0.2.1', 389])

Parameters:

  • host (Optional[Variant[Postfix::Type::Lookup::LDAP::Host, Postfix::Type::Lookup::MySQL::Host, Postfix::Type::Lookup::PgSQL::Host, Postfix::Type::Lookup::Memcache::Host]])

    The host to flatten, `undef` is passed through.

Returns:

  • (Optional[String])

    The flattened string.

Since:

  • 2.0.0



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'vendor_modules/postfix/functions/flatten_host.pp', line 12

function postfix::flatten_host(Optional[Variant[Postfix::Type::Lookup::LDAP::Host, Postfix::Type::Lookup::MySQL::Host, Postfix::Type::Lookup::PgSQL::Host, Postfix::Type::Lookup::Memcache::Host]] $host) {

  $host ? {
    undef   => undef,
    default => type($host) ? {
      Type[Tuple]           => join($host.map |$x| {
        type($x) ? {
          Type[Bodgitlib::Host] => bodgitlib::enclose_ipv6($x), # lint:ignore:unquoted_string_in_selector FIXME
          default               => $x,
        }
      }, ':'),
      Type[Bodgitlib::Host] => bodgitlib::enclose_ipv6($host), # lint:ignore:unquoted_string_in_selector FIXME
      default               => $host,
    },
  }
}