Method: Chef::DSL::DeclareResource#edit_resource
- Defined in:
- lib/chef/dsl/declare_resource.rb
#edit_resource(type, name, created_at: nil, run_context: self.run_context, &resource_attrs_block) ⇒ Chef::Resource
Lookup a resource in the resource collection by name. If it exists, return it. If it does not exist, create it. This is a useful function for accumulator patterns. In CRUD terminology this is an “upsert” operation and is used to assert that the resource must exist with the specified properties.
156 157 158 159 160 |
# File 'lib/chef/dsl/declare_resource.rb', line 156 def edit_resource(type, name, created_at: nil, run_context: self.run_context, &resource_attrs_block) edit_resource!(type, name, created_at: created_at, run_context: run_context, &resource_attrs_block) rescue Chef::Exceptions::ResourceNotFound declare_resource(type, name, created_at: created_at, run_context: run_context, &resource_attrs_block) end |