Puppet Function: tp::url_replace

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

Overview

tp::url_replace(String $url, String $_version, Optional[String] $_majversion = undef)Any

Function tp::url_replace. Gets an url and coverts is based on a given map

Parameters:

  • url (String)
  • _version (String)
  • _majversion (Optional[String]) (defaults to: undef)

Returns:

  • (Any)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'functions/url_replace.pp', line 3

function tp::url_replace (
  String $url,
  String $_version,
  Optional[String] $_majversion = undef,
) {
  # TODO: Improve and make dynamic when needed
  $translated_arch = $facts['os']['architecture'] ? {
    'x86_64' => 'amd64',
    'x64'    => 'amd64',
    'i386'   => '386',
    default  => pick_default($facts['os']['architecture'], ''),
  }
  $versioned_url = regsubst($url,'\$VERSION', $_version, 'G')
  if $_majversion == undef {
    $majversioned_url = $versioned_url
  } else {
    $majversioned_url = regsubst($versioned_url,'\$MAJVERSION', $_majversion, 'G')
  }
  $os_replaced_url = regsubst($majversioned_url,'\$OS', downcase($facts['kernel']), 'G')
  $arch_replaced_url = regsubst($os_replaced_url,'\$ARCH', downcase($translated_arch), 'G') # lint:ignore:140chars

  return $arch_replaced_url
}