Puppet Function: validate_raw_constructor

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

Overview

validate_raw_constructor()Any

Specialized function used to validate raw constructor class resource hashes. Expects the value of each key in the resource param to be Hash. If the value is not a Hash it’s rejected. If the the Hash is exhausted, the resource is “validated”.

Returns:

  • (Any)


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

newfunction(:validate_raw_constructor, :doc => <<-EOS
Specialized function used to validate raw constructor class resource hashes.
Expects the value of each key in the resource param to be Hash. If the value is
not a Hash it's rejected. If the the Hash is exhausted, the resource is
"validated".
  EOS
) do |args|

  e = "validate_raw_constructor(): Wrong number of args: #{args.size} for 1"
  raise(Puppet::ParseError, e) if args.size != 1

  resources = args.first.dup
  resources.reject! { |k,v| v.respond_to? :key }

  e = "one or more invalid resources: #{resources}"
  raise(Puppet::ParseError, e) unless resources.empty?
end