Puppet Function: patching::target_names

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

Summary

Returns an array of names, one for each target, based on the $name_property

Overview

patching::target_names(TargetSpec $targets, Enum['hostname', 'name', 'uri'] $name_property)Array[String]

Parameters:

  • targets (TargetSpec)

    List of targets to extract the name from

  • name_property (Enum['hostname', 'name', 'uri'])

    Property in the Target to use as the name

Returns:

  • (Array[String])

    Array of names, one for each target



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'functions/target_names.pp', line 10

function patching::target_names(
  TargetSpec          $targets,
  Enum['hostname', 'name', 'uri'] $name_property,
) >> Array[String] {
  $targets.map |$n| {
    case $name_property {
      'hostname': {
        regsubst($n.uri, '^([^.]+).*','\1')
      }
      'name': {
        $n.name
      }
      'uri': {
        $n.uri
      }
      default: {
        fail_plan("Unsupported patching_target_name_property: ${name_property}")
      }
    }
  }
}