Puppet Function: pontoon::service_names

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

Summary

Map each service to its 'names'. Names include the service name itself and any configured discovery names.

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

SPDX-License-Identifier: Apache-2.0

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:



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

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