Puppet Function: pontoon::service_names

Defined in:
modules/pontoon/functions/service_names.pp
Function type:
Puppet Language

Overview

pontoon::service_names(Hash[String, Wmflib::Service] $services_config, Array[String] $domains = ['discovery', 'svc.eqiad', 'svc.codfw'], String $tld = 'wmnet')Hash[String, Array[String]]

Parameters:

  • services_config (Hash[String, Wmflib::Service])

    The Wmflib::Service configuration to inspect

  • domains (Array[String]) (defaults to: ['discovery', 'svc.eqiad', 'svc.codfw'])

    The domains to map services to

  • tld (String) (defaults to: 'wmnet')

    The network's TLD

Returns:



6
7
8
9
10
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
# File 'modules/pontoon/functions/service_names.pp', line 6

function pontoon::service_names(
    Hash[String, Wmflib::Service] $services_config,
    Array[String] $domains = ['discovery', 'svc.eqiad', 'svc.codfw'],
    String $tld = 'wmnet',
) >> Hash[String, Array[String]] {
    $t = $services_config.map |$service_name, $config| {
        $disc_names = ('discovery' in $config) ? {
          true  => $config['discovery'].map |$el| { $el['dnsdisc'] },
          false => [],
        }
        $aliases = ('aliases' in $config) ? {
          true  => $config['aliases'],
          false => [],
        }
        $all_names = unique($disc_names + $aliases + $service_name)

        $svc_names = $domains.map |$d| {
            $all_names.map |$n| {
                [ "${n}.${d}.${tld}" ]
            }
        }

        [
            $service_name,
            $svc_names.flatten().sort(),
        ]
    }

    Hash($t)
}