chef
https://github.com/opscode/chef
Ruby
A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure.
Chef::ChefFS::ChefFSDataStore#create
If you want to get the contents of /data/x/y from the server,
you say chef_fs.child('data').child('x').child('y').read.
It will make exactly one network request: GET /data/x/y
And that will return 404 if it doesn't exist.
ChefFS objects do not go to the network until you ask them for data.
This means you can construct a /data/x/y ChefFS entry early.
Alternative:
chef_fs.child('data') could have done a GET /data preemptively,
allowing it to know whether child('x') was valid (GET /data gives you
a list of data bags). Then child('x') could have done a GET /data/x,
allowing it to know whether child('y') (the item) existed. Finally,
we would do the GET /data/x/y to read the contents. Three network
requests instead of 1.Edit
git clone [email protected]:opscode/chef.git
cd chef
open lib/chef/chef_fs/chef_fs_data_store.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Chef--ChefFS--ChefFSDataStore-create-for-pr
# Commit to gitgit add lib/chef/chef_fs/chef_fs_data_store.rbgit commit -m "better docs for Chef::ChefFS::ChefFSDataStore#create"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-Chef--ChefFS--ChefFSDataStore-create-for-pr
hub pull-request
# Celebrate!