Class: Puppet::Resource
- Extended by:
- Indirector
- Includes:
- Enumerable, Util::Tagging
- Defined in:
- lib/puppet/resource.rb,
lib/puppet/resource/status.rb
Overview
The simplest resource class. Eventually it will function as the base class for all resource-like behaviour.
Direct Known Subclasses
Defined Under Namespace
Modules: CapabilityFinder, Validator Classes: Catalog, Ral, Status, StoreConfigs, Type, TypeCollection
Constant Summary collapse
- ATTRIBUTES =
[:file, :line, :exported].freeze
- TYPE_CLASS =
'Class'.freeze
- TYPE_NODE =
'Node'.freeze
- TYPE_SITE =
'Site'.freeze
- PCORE_TYPE_KEY =
'__pcore_type__'.freeze
- VALUE_KEY =
'value'.freeze
- YAML_ATTRIBUTES =
[:@file, :@line, :@exported, :@type, :@title, :@tags, :@parameters]
Constants included from Indirector
Constants included from Util::Tagging
Instance Attribute Summary collapse
- #catalog ⇒ Object
- #exported ⇒ Object
- #file ⇒ Object
- #line ⇒ Object
-
#sensitive_parameters ⇒ Array<Symbol>
private
A list of parameters to be treated as sensitive.
- #strict ⇒ Object
- #title ⇒ Object readonly
- #type ⇒ Object readonly
- #validate_parameters ⇒ Object deprecated Deprecated.
- #virtual ⇒ Object
Class Method Summary collapse
- .from_data_hash(data, rich_data_enabled = false) ⇒ Object
-
.resource_type(type, title, environment) ⇒ Puppet::Type, Puppet::Resource::Type
private
The resource’s type implementation.
- .type_and_title(type, title) ⇒ Object private
- .value_to_pson_data(value) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#[](param) ⇒ Object
Return a given parameter’s value.
-
#[]=(param, value) ⇒ Object
Set a given parameter.
-
#builtin? ⇒ Boolean
Compatibility method.
-
#builtin_type? ⇒ Boolean
Is this a builtin resource type?.
- #class? ⇒ Boolean
- #copy_as_resource ⇒ Object
-
#each ⇒ Object
Iterate over each param/value pair, as required for Enumerable.
- #environment ⇒ Object
- #environment=(environment) ⇒ Object
-
#export ⇒ Object
private
Returns the value of the ‘export’ metaparam as an Array.
- #include?(parameter) ⇒ Boolean
-
#initialize(type, title = nil, attributes = {}) ⇒ Resource
constructor
Construct a resource from data.
- #inspect ⇒ Object
-
#is_application_component? ⇒ Boolean
A resource is an application component if it exports or consumes one or more capabilities, or if it requires a capability resource.
-
#is_capability? ⇒ Boolean
A resource is a capability (instance) if its underlying type is a capability type.
-
#is_json_type?(value) ⇒ Boolean
private
‘true` if the value can be represented as JSON.
- #key_attributes ⇒ Object
- #name ⇒ Object
- #prune_parameters(options = {}) ⇒ Object
- #ref ⇒ Object
-
#resolve ⇒ Object
Find our resource.
-
#resource_type ⇒ Puppet::Type, Puppet::Resource::Type
private
The resource’s type implementation.
-
#resource_type=(type) ⇒ Object
private
Set the resource’s type implementation.
-
#set_default_parameters(scope) ⇒ Object
deprecated
private
Deprecated.
Not used by Puppet
- #stage? ⇒ Boolean
- #to_data_hash(rich_data_enabled = false) ⇒ Object
-
#to_hash ⇒ Object
Produce a simple hash of our parameters.
-
#to_hierayaml ⇒ Object
Convert our resource to yaml for Hiera purposes.
-
#to_manifest ⇒ Object
Convert our resource to Puppet code.
-
#to_ral ⇒ Object
Convert our resource to a RAL resource instance.
- #to_ref ⇒ Object
- #to_s ⇒ Object
-
#to_yaml_properties ⇒ Array<Symbol>
private
Explicitly list the instance variables that should be serialized when converting to YAML.
- #uniqueness_key ⇒ Object
- #valid_parameter?(name) ⇒ Boolean
-
#validate_complete ⇒ Object
deprecated
private
Deprecated.
Not used by Puppet
- #validate_parameter(name) ⇒ Object
- #yaml_property_munge(x) ⇒ Object
Methods included from Indirector
Methods included from Util::Tagging
#merge_into, #merge_tags, #raw_tagged?, #set_tags, #tag, #tag_if_valid, #tagged?, #tags, #tags=
Constructor Details
#initialize(type, title = nil, attributes = {}) ⇒ Resource
Construct a resource from data.
Constructs a resource instance with the given ‘type` and `title`. Multiple type signatures are possible for these arguments and most will result in an expensive call to Node::Environment#known_resource_types in order to resolve `String` and `Symbol` Types to actual Ruby classes.
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'lib/puppet/resource.rb', line 288 def initialize(type, title = nil, attributes = {}) @parameters = {} @sensitive_parameters = [] if type.is_a?(Puppet::Resource) # Copy constructor. Let's avoid munging, extracting, tagging, etc src = type self.file = src.file self.line = src.line self.exported = src.exported self.virtual = src.virtual self.(src) self.environment = src.environment @rstype = src.resource_type @type = src.type @title = src.title src.to_hash.each do |p, v| if v.is_a?(Puppet::Resource) v = v.copy_as_resource elsif v.is_a?(Array) # flatten resource references arrays v = v.flatten if v.flatten.find { |av| av.is_a?(Puppet::Resource) } v = v.collect do |av| av = av.copy_as_resource if av.is_a?(Puppet::Resource) av end end self[p] = v end @sensitive_parameters.replace(type.sensitive_parameters) else if type.is_a?(Hash) raise ArgumentError, "Puppet::Resource.new does not take a hash as the first argument. "+ "Did you mean (#{(type[:type] || type["type"]).inspect}, #{(type[:title] || type["title"]).inspect }) ?" end environment = attributes[:environment] # In order to avoid an expensive search of 'known_resource_types" and # to obey/preserve the implementation of the resource's type - if the # given type is a resource type implementation (one of): # * a "classic" 3.x ruby plugin # * a compatible implementation (e.g. loading from pcore metadata) # * a resolved user defined type # # ...then, modify the parameters to the "old" (agent side compatible) way # of describing the type/title with string/symbols. # # TODO: Further optimizations should be possible as the "type juggling" is # not needed when the type implementation is known. # if type.is_a?(Puppet::CompilableResourceType) || type.is_a?(Puppet::Resource::Type) # set the resource type implementation self.resource_type = type # set the type name to the symbolic name type = type.name end # Set things like strictness first. attributes.each do |attr, value| next if attr == :parameters send(attr.to_s + "=", value) end @type, @title = self.class.type_and_title(type, title) rt = resource_type if strict? && rt.nil? if self.class? raise ArgumentError, "Could not find declared class #{title}" else raise ArgumentError, "Invalid resource type #{type}" end end params = attributes[:parameters] unless params.nil? || params.empty? extract_parameters(params) if rt && rt.respond_to?(:deprecate_params) rt.deprecate_params(title, params) end end tag(self.type) tag_if_valid(self.title) end end |
Instance Attribute Details
#sensitive_parameters ⇒ Array<Symbol>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns A list of parameters to be treated as sensitive.
19 20 21 |
# File 'lib/puppet/resource.rb', line 19 def sensitive_parameters @sensitive_parameters end |
#validate_parameters ⇒ Object
22 23 24 |
# File 'lib/puppet/resource.rb', line 22 def validate_parameters @validate_parameters end |
Class Method Details
.from_data_hash(data, rich_data_enabled = false) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/puppet/resource.rb', line 36 def self.from_data_hash(data, rich_data_enabled = false) raise ArgumentError, "No resource type provided in serialized data" unless type = data['type'] raise ArgumentError, "No resource title provided in serialized data" unless title = data['title'] resource = new(type, title) if params = data['parameters'] params.each do |param, value| value = convert_rich_data_hash(value, rich_data_enabled) if value.is_a?(Hash) && value.include?(PCORE_TYPE_KEY) resource[param] = value end end if sensitive_parameters = data['sensitive_parameters'] resource.sensitive_parameters = sensitive_parameters.map(&:to_sym) end if = data['tags'] .each { |tag| resource.tag(tag) } end ATTRIBUTES.each do |a| if value = data[a.to_s] resource.send(a.to_s + "=", value) end end resource end |
.resource_type(type, title, environment) ⇒ Puppet::Type, Puppet::Resource::Type
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The resource’s type implementation
419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
# File 'lib/puppet/resource.rb', line 419 def self.resource_type(type, title, environment) case type when TYPE_CLASS; environment.known_resource_types.hostclass(title == :main ? "" : title) when TYPE_NODE; environment.known_resource_types.node(title) when TYPE_SITE; environment.known_resource_types.site(nil) else result = Puppet::Type.type(type) if !result krt = environment.known_resource_types result = krt.definition(type) || krt.application(type) end result end end |
.type_and_title(type, title) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
633 634 635 636 637 638 639 640 |
# File 'lib/puppet/resource.rb', line 633 def self.type_and_title(type, title) type, title = extract_type_and_title(type, title) type = munge_type_name(type) if type == TYPE_CLASS title = title == '' ? :main : munge_type_name(title) end [type, title] end |
.value_to_pson_data(value) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/puppet/resource.rb', line 170 def self.value_to_pson_data(value) if value.is_a?(Array) value.map{|v| value_to_pson_data(v) } elsif value.is_a?(Hash) result = {} value.each_pair { |k, v| result[value_to_pson_data(k)] = value_to_pson_data(v) } result elsif value.is_a?(Puppet::Resource) value.to_s elsif value.is_a?(Symbol) && value == :undef nil else value end end |
Instance Method Details
#==(other) ⇒ Object
223 224 225 226 227 228 |
# File 'lib/puppet/resource.rb', line 223 def ==(other) return false unless other.respond_to?(:title) and self.type == other.type and self.title == other.title return false unless to_hash == other.to_hash true end |
#[](param) ⇒ Object
Return a given parameter’s value. Converts all passed names to lower-case symbols.
219 220 221 |
# File 'lib/puppet/resource.rb', line 219 def [](param) parameters[parameter_name(param)] end |
#[]=(param, value) ⇒ Object
Set a given parameter. Converts all passed names to lower-case symbols.
212 213 214 215 |
# File 'lib/puppet/resource.rb', line 212 def []=(param, value) validate_parameter(param) if validate_parameters parameters[parameter_name(param)] = value end |
#builtin? ⇒ Boolean
Compatibility method.
231 232 233 234 |
# File 'lib/puppet/resource.rb', line 231 def builtin? # TODO: should be deprecated (was only used in one place in puppet codebase) builtin_type? end |
#builtin_type? ⇒ Boolean
Is this a builtin resource type?
237 238 239 240 |
# File 'lib/puppet/resource.rb', line 237 def builtin_type? # Note - old implementation only checked if the resource_type was a Class resource_type.is_a?(Puppet::CompilableResourceType) end |
#class? ⇒ Boolean
257 258 259 |
# File 'lib/puppet/resource.rb', line 257 def class? @is_class ||= @type == TYPE_CLASS end |
#copy_as_resource ⇒ Object
574 575 576 |
# File 'lib/puppet/resource.rb', line 574 def copy_as_resource Puppet::Resource.new(self) end |
#each ⇒ Object
Iterate over each param/value pair, as required for Enumerable.
243 244 245 |
# File 'lib/puppet/resource.rb', line 243 def each parameters.each { |p,v| yield p, v } end |
#environment ⇒ Object
441 442 443 444 445 446 447 |
# File 'lib/puppet/resource.rb', line 441 def environment @environment ||= if catalog catalog.environment_instance else Puppet.lookup(:current_environment) { Puppet::Node::Environment::NONE } end end |
#environment=(environment) ⇒ Object
449 450 451 |
# File 'lib/puppet/resource.rb', line 449 def environment=(environment) @environment = environment end |
#export ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the value of the ‘export’ metaparam as an Array
404 405 406 407 |
# File 'lib/puppet/resource.rb', line 404 def export v = self[:export] || [] v.is_a?(Array) ? v : [ v ] end |
#include?(parameter) ⇒ Boolean
247 248 249 |
# File 'lib/puppet/resource.rb', line 247 def include?(parameter) super || parameters.keys.include?( parameter_name(parameter) ) end |
#inspect ⇒ Object
90 91 92 |
# File 'lib/puppet/resource.rb', line 90 def inspect "#{@type}[#{@title}]#{to_hash.inspect}" end |
#is_application_component? ⇒ Boolean
A resource is an application component if it exports or consumes one or more capabilities, or if it requires a capability resource
388 389 390 391 392 393 394 |
# File 'lib/puppet/resource.rb', line 388 def is_application_component? return true if ! export.empty? || self[:consume] # Array(self[:require]) does not work for Puppet::Resource instances req = self[:require] || [] req = [ req ] unless req.is_a?(Array) req.any? { |r| r.is_capability? } end |
#is_capability? ⇒ Boolean
A resource is a capability (instance) if its underlying type is a capability type
398 399 400 |
# File 'lib/puppet/resource.rb', line 398 def is_capability? !resource_type.nil? && resource_type.is_capability? end |
#is_json_type?(value) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns ‘true` if the value can be represented as JSON.
157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/puppet/resource.rb', line 157 def is_json_type?(value) case value when NilClass, TrueClass, FalseClass, Integer, Float, String true when Array value.all? { |elem| is_json_type?(elem) } when Hash value.all? { |key, val| key.is_a?(String) && is_json_type?(val) } else false end end |
#key_attributes ⇒ Object
471 472 473 |
# File 'lib/puppet/resource.rb', line 471 def key_attributes resource_type.respond_to?(:key_attributes) ? resource_type.key_attributes : [:name] end |
#name ⇒ Object
527 528 529 530 531 532 |
# File 'lib/puppet/resource.rb', line 527 def name # this is potential namespace conflict # between the notion of an "indirector name" # and a "resource name" [ type, title ].join('/') end |
#prune_parameters(options = {}) ⇒ Object
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 |
# File 'lib/puppet/resource.rb', line 616 def prune_parameters( = {}) properties = resource_type.properties.map(&:name) dup.collect do |attribute, value| if value.to_s.empty? or Array(value).empty? delete(attribute) elsif value.to_s == "absent" and attribute.to_s != "ensure" delete(attribute) end parameters_to_include = [:parameters_to_include] || [] delete(attribute) unless properties.include?(attribute) || parameters_to_include.include?(attribute) end self end |
#resolve ⇒ Object
Find our resource.
382 383 384 |
# File 'lib/puppet/resource.rb', line 382 def resolve catalog ? catalog.resource(to_s) : nil end |
#resource_type ⇒ Puppet::Type, Puppet::Resource::Type
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The resource’s type implementation
412 413 414 |
# File 'lib/puppet/resource.rb', line 412 def resource_type @rstype ||= self.class.resource_type(type, title, environment) end |
#resource_type=(type) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set the resource’s type implementation
437 438 439 |
# File 'lib/puppet/resource.rb', line 437 def resource_type=(type) @rstype = type end |
#set_default_parameters(scope) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Not used by Puppet
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 |
# File 'lib/puppet/resource.rb', line 544 def set_default_parameters(scope) Puppet.deprecation_warning('The method Puppet::Resource.set_default_parameters is deprecated and will be removed in the next major release of Puppet.') return [] unless resource_type and resource_type.respond_to?(:arguments) unless is_a?(Puppet::Parser::Resource) fail Puppet::DevError, "Cannot evaluate default parameters for #{self} - not a parser resource" end missing_arguments.collect do |param, default| rtype = resource_type if rtype.type == :hostclass using_bound_value = false catch(:no_such_key) do bound_value = Puppet::Pops::Lookup.search_and_merge("#{rtype.name}::#{param}", Puppet::Pops::Lookup::Invocation.new(scope), nil) # Assign bound value but don't let an undef trump a default expression unless bound_value.nil? && !default.nil? self[param.to_sym] = bound_value using_bound_value = true end end end unless using_bound_value next if default.nil? self[param.to_sym] = default.safeevaluate(scope) end param end.compact end |
#stage? ⇒ Boolean
261 262 263 |
# File 'lib/puppet/resource.rb', line 261 def stage? @is_stage ||= @type.to_s.downcase == "stage" end |
#to_data_hash(rich_data_enabled = false) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/puppet/resource.rb', line 94 def to_data_hash(rich_data_enabled = false) data = ([:type, :title, :tags] + ATTRIBUTES).inject({}) do |hash, param| next hash unless value = self.send(param) hash[param.to_s] = value hash end data["exported"] ||= false ext_params = {} params = {} self.to_hash.each_pair do |param, value| # Don't duplicate the title as the namevar unless param == namevar && value == title value = Puppet::Resource.value_to_pson_data(value) if is_json_type?(value) params[param] = value elsif !rich_data_enabled Puppet.warning("Resource '#{to_s}' contains a #{value.class.name} value. It will be converted to the String '#{value}'") params[param] = value else ext_params[param] = value end end end unless ext_params.empty? tc = Puppet::Pops::Types::TypeCalculator.singleton sc = Puppet::Pops::Types::StringConverter.singleton ext_params.each_pair do |key, value| pcore_type = tc.infer(value) # Don't allow unknown runtime types to leak into the catalog raise Puppet::Error, _('No Puppet Type found for %{type_name}') % { :type_name => value.class.name } if pcore_type.is_a?(Puppet::Pops::Types::PRuntimeType) if value.is_a?(Hash) || value.is_a?(Array) || value.is_a?(Puppet::Pops::Types::PuppetObject) # Non scalars and Objects are serialized into an array using Pcore json_serializer ||= Puppet::Pops::Serialization::Serializer.new(Puppet::Pops::Serialization::JSON::Writer.new(''), :type_by_reference => true) writer = json_serializer.writer writer.clear_io json_serializer.write(value) writer.finish value = writer.to_a else # Scalar values are stored using their default string representation value = sc.convert(value) end params[key] = { PCORE_TYPE_KEY => pcore_type.name, VALUE_KEY => value } end end data['parameters'] = params unless params.empty? data["sensitive_parameters"] = sensitive_parameters unless sensitive_parameters.empty? data end |
#to_hash ⇒ Object
Produce a simple hash of our parameters.
454 455 456 |
# File 'lib/puppet/resource.rb', line 454 def to_hash parse_title.merge parameters end |
#to_hierayaml ⇒ Object
Convert our resource to yaml for Hiera purposes.
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
# File 'lib/puppet/resource.rb', line 476 def to_hierayaml # Collect list of attributes to align => and move ensure first attr = parameters.keys attr_max = attr.inject(0) { |max,k| k.to_s.length > max ? k.to_s.length : max } attr.sort! if attr.first != :ensure && attr.include?(:ensure) attr.delete(:ensure) attr.unshift(:ensure) end attributes = attr.collect { |k| v = parameters[k] " %-#{attr_max}s: %s\n" % [k, Puppet::Parameter.format_value_for_display(v)] }.join " %s:\n%s" % [self.title, attributes] end |
#to_manifest ⇒ Object
Convert our resource to Puppet code.
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
# File 'lib/puppet/resource.rb', line 496 def to_manifest # Collect list of attributes to align => and move ensure first attr = parameters.keys attr_max = attr.inject(0) { |max,k| k.to_s.length > max ? k.to_s.length : max } attr.sort! if attr.first != :ensure && attr.include?(:ensure) attr.delete(:ensure) attr.unshift(:ensure) end attributes = attr.collect { |k| v = parameters[k] " %-#{attr_max}s => %s,\n" % [k, Puppet::Parameter.format_value_for_display(v)] }.join escaped = self.title.gsub(/'/,"\\\\'") "%s { '%s':\n%s}" % [self.type.to_s.downcase, escaped, attributes] end |
#to_ral ⇒ Object
Convert our resource to a RAL resource instance. Creates component instances for resource types that don’t exist.
522 523 524 525 |
# File 'lib/puppet/resource.rb', line 522 def to_ral typeklass = Puppet::Type.type(self.type) || Puppet::Type.type(:component) typeklass.new(self) end |
#to_s ⇒ Object
458 459 460 |
# File 'lib/puppet/resource.rb', line 458 def to_s "#{type}[#{title}]" end |
#to_yaml_properties ⇒ Array<Symbol>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Explicitly list the instance variables that should be serialized when converting to YAML.
198 199 200 |
# File 'lib/puppet/resource.rb', line 198 def to_yaml_properties YAML_ATTRIBUTES & super end |
#uniqueness_key ⇒ Object
462 463 464 465 466 467 468 469 |
# File 'lib/puppet/resource.rb', line 462 def uniqueness_key # Temporary kludge to deal with inconsistent use patterns; ensure we don't return nil for namevar/:name h = self.to_hash name = h[namevar] || h[:name] || self.name h[namevar] ||= name h[:name] ||= name h.values_at(*key_attributes.sort_by { |k| k.to_s }) end |
#valid_parameter?(name) ⇒ Boolean
578 579 580 |
# File 'lib/puppet/resource.rb', line 578 def valid_parameter?(name) resource_type.valid_parameter?(name) end |
#validate_complete ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Not used by Puppet
Verify that all required arguments are either present or have been provided with defaults. Must be called after ‘set_default_parameters’. We can’t join the methods because Type#set_parameters needs specifically ordered behavior.
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 |
# File 'lib/puppet/resource.rb', line 589 def validate_complete Puppet.deprecation_warning('The method Puppet::Resource.validate_complete is deprecated and will be removed in the next major release of Puppet.') return unless resource_type and resource_type.respond_to?(:arguments) resource_type.arguments.each do |param, default| param = param.to_sym fail Puppet::ParseError, "Must pass #{param} to #{self}" unless parameters.include?(param) end # Perform optional type checking arg_types = resource_type.argument_types # Parameters is a map from name, to parameter, and the parameter again has name and value parameters.each do |name, value| next unless t = arg_types[name.to_s] # untyped, and parameters are symbols here (aargh, strings in the type) unless Puppet::Pops::Types::TypeCalculator.instance?(t, value.value) inferred_type = Puppet::Pops::Types::TypeCalculator.infer_set(value.value) actual = inferred_type.generalize() fail Puppet::ParseError, "Expected parameter '#{name}' of '#{self}' to have type #{t.to_s}, got #{actual.to_s}" end end end |
#validate_parameter(name) ⇒ Object
612 613 614 |
# File 'lib/puppet/resource.rb', line 612 def validate_parameter(name) raise Puppet::ParseError.new("no parameter named '#{name}'", file, line) unless valid_parameter?(name) end |
#yaml_property_munge(x) ⇒ Object
186 187 188 |
# File 'lib/puppet/resource.rb', line 186 def yaml_property_munge(x) self.value.to_pson_data(x) end |