Method: Chef::Resource::Notification#fix_resource_reference
- Defined in:
- lib/chef/resource.rb
#fix_resource_reference(resource_collection) ⇒ Object
This will look up the resource if it is not a Resource Object. It will complain if it finds multiple resources, can’t find a resource, or gets invalid syntax.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/chef/resource.rb', line 61 def fix_resource_reference(resource_collection) matching_resource = resource_collection.find(resource) if Array(matching_resource).size > 1 msg = "Notification #{self} from #{} was created with a reference to multiple resources, "\ "but can only notify one resource. Notifying resource was defined on #{.source_line}" raise Chef::Exceptions::InvalidResourceReference, msg end self.resource = matching_resource rescue Chef::Exceptions::ResourceNotFound => e err = Chef::Exceptions::ResourceNotFound.new(<<-FAIL) resource #{} is configured to notify resource #{resource} with action #{action}, \ but #{resource} cannot be found in the resource collection. #{} is defined in \ #{.source_line} FAIL err.set_backtrace(e.backtrace) raise err rescue Chef::Exceptions::InvalidResourceSpecification => e err = Chef::Exceptions::InvalidResourceSpecification.new(<<-F) Resource #{} is configured to notify resource #{resource} with action #{action}, \ but #{resource.inspect} is not valid syntax to look up a resource in the resource collection. Notification \ is defined near #{.source_line} F err.set_backtrace(e.backtrace) raise err end |