chef
https://github.com/opscode/chef
Ruby
A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure.
Chef::ResourceCollection::ResourceList#insert
If @insert_after_idx is nil, we are not currently executing a converge so the Resource is appended to the
end of the list. If @insert_after_idx is NOT nil, we ARE currently executing a converge so the resource
is inserted into the middle of the list after the last resource that was converged. If it is called multiple
times (when an LWRP contains multiple resources) it keeps track of that. See this example ResourceList:
[File1, LWRP1, File2] # The iterator starts and points to File1. It is executed and @insert_after_idx=0
[File1, LWRP1, File2] # The iterator moves to LWRP1. It is executed and @insert_after_idx=1
[File1, LWRP1, Service1, File2] # The LWRP execution inserts Service1 and @insert_after_idx=2
[File1, LWRP1, Service1, Service2, File2] # The LWRP inserts Service2 and @insert_after_idx=3. The LWRP
finishes executing
[File1, LWRP1, Service1, Service2, File2] # The iterator moves to Service1 since it is the next non-executed
resource. The execute_each_resource call below resets @insert_after_idx=2
If Service1 was another LWRP, it would insert its resources between Service1 and Service2. The iterator keeps
track of executed resources and @insert_after_idx keeps track of where the next resource to insert should be.Edit
git clone [email protected]:opscode/chef.git
cd chef
open lib/chef/resource_collection/resource_list.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Chef--ResourceCollection--ResourceList-insert-for-pr
# Commit to gitgit add lib/chef/resource_collection/resource_list.rbgit commit -m "better docs for Chef::ResourceCollection::ResourceList#insert"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-Chef--ResourceCollection--ResourceList-insert-for-pr
hub pull-request
# Celebrate!