Puppet Function: load_module_metadata

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

Overview

load_module_metadata()Any

Returns:

  • (Any)


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'puppet/modules/stdlib/lib/puppet/parser/functions/load_module_metadata.rb', line 2

newfunction(:load_module_metadata, :type => :rvalue, :doc => <<-EOT
EOT
) do |args|
  raise(Puppet::ParseError, "load_module_metadata(): Wrong number of arguments, expects one or two") unless [1,2].include?(args.size)
  mod = args[0]
   = args[1]
  module_path = function_get_module_path([mod])
   = File.join(module_path, 'metadata.json')

   = File.exists?()
  if 
     = PSON.load(File.read())
  else
    if 
       = {}
    else
      raise(Puppet::ParseError, "load_module_metadata(): No metadata.json file for module #{mod}")
    end
  end

  return 
end