Puppet Function: mrepo_munge

Defined in:
lib/puppet/parser/functions/mrepo_munge.rb
Function type:
Ruby 3.x API

Overview

mrepo_munge()Any

Processes mrepo::repo names and collapses them to match mrepo standards.

Returns:

  • (Any)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/puppet/parser/functions/mrepo_munge.rb', line 1

Puppet::Parser::Functions.newfunction(:mrepo_munge, type: :rvalue, doc: <<-EOS
  Processes mrepo::repo names and collapses them to match mrepo standards.
EOS
) do |arguments|
  raise Puppet::ParseError, "mrepo_munge(): Wrong number of arguments given (#{arguments.length} for 2)" unless arguments.length == 2

  reponame     = arguments[0]
  architecture = arguments[1]

  raise Puppet::ParseError, "mrepo_munge() takes (String, String), received (#{reponame.class}, #{architecture.class})" unless reponame.is_a?(String) && architecture.is_a?(String)

  collapsible_arches = %w[alpha i386 ia64 ppc ppc64 x86_64 sparc64 sparc64v s390 s390x]

  if collapsible_arches.include?(architecture) && reponame.match(%r{^.*-#{architecture}$})
    reponame
  else
    "#{reponame}-#{architecture}"
  end
end