summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaire McQuin <claire@getchef.com>2014-09-04 15:37:53 -0700
committerClaire McQuin <claire@getchef.com>2014-09-04 16:00:18 -0700
commit62d1c23d472f4b2eabad8f7f108f65886136c104 (patch)
tree4592fc4b28908634c406a8ae115b5e2412f4cb48
parent8022a0d89a85787a4b6550428ab26ae37b09b8c0 (diff)
downloadchef-62d1c23d472f4b2eabad8f7f108f65886136c104.tar.gz
Update for search filtering.
-rw-r--r--CHANGELOG.md1
-rw-r--r--DOC_CHANGES.md59
-rw-r--r--RELEASE_NOTES.md6
3 files changed, 66 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c160fae749..471a00500f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -117,6 +117,7 @@
* Deprecate --distro / --template_file options in favor of --boostrap-template
* Add `:node_ssl_verify_mode` & `:node_verify_api_cert` options to bootstrap
to be able to configure these settings on the bootstrapped node.
+* Add partial_search dsl method to Chef::Search::Query, add result filtering to search.
## Last Release: 11.14.2
diff --git a/DOC_CHANGES.md b/DOC_CHANGES.md
index c08ab0097a..a52dc3320e 100644
--- a/DOC_CHANGES.md
+++ b/DOC_CHANGES.md
@@ -89,3 +89,62 @@ Note that the service resource will also continue to set the startup type to aut
DSL method `data_bag_item` now takes an optional String parameter `secret`, which is used to interact with encrypted data bag items.
If the data bag item being fetched is encrypted and no `secret` is provided, Chef looks for a secret at `Chef::Config[:encrypted_data_bag_secret]`.
If `secret` is provided, but the data bag item is not encrypted, then a regular data bag item is returned (no decryption is attempted).
+
+### New configurable option :yum-lock-timeout
+You can now set the timeout for receiving the yum lock in `config.rb` by adding `yum-lock-timeout SECONDS` (default is 30 seconds).
+
+### Enhanced search functionality: result filtering
+#### Use in recipes
+`Chef::Search::Query#search` can take an optional `:filter_result` argument which returns search data in the form of the Hash specified. Suppose your data looks like
+```json
+{"languages": {
+ "c": {
+ "gcc": {
+ "version": "4.6.3",
+ "description": "gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) "
+ }
+ },
+ "ruby": {
+ "platform": "x86_64-linux",
+ "version": "1.9.3",
+ "release_date": "2013-11-22"
+ },
+ "perl": {
+ "version": "5.14.2",
+ "archname": "x86_64-linux-gnu-thread-multi"
+ },
+ "python": {
+ "version": "2.7.3",
+ "builddate": "Feb 27 2014, 19:58:35"
+ }
+}}
+```
+for a node running Ubuntu named `node01`, and you want to get back only information on which versions of c and ruby you have. In a recipe you would write
+```ruby
+search(:node, "platform:ubuntu", :filter_result => {"c_version" => ["languages", "c", "gcc", "version"],
+ "ruby_version" => ["languages", "ruby", "version"]})
+```
+and receive
+```ruby
+[
+ {"url" => "https://api.opscode.com/organization/YOUR_ORG/nodes/node01",
+ "data" => {"c_version" => "4.6.3", "ruby_version" => "1.9.3"},
+ # snip other Ubuntu nodes
+]
+```
+If instead you wanted all the languages data (remember, `"languages"` is only one tiny piece of information the Chef Server stores about your node), you would have `:filter_result => {"languages" => ["laguages"]}` in your search query.
+
+For backwards compatibility, a `partial_search` method has been added to `Chef::Search::Query` which can be used in the same way as the `partial_search` method from the [partial_search cookbook](https://supermarket.getchef.com/cookbooks/partial_search). Note that this method has been deprecated and will be removed in future versions of Chef.
+
+#### Use in knife
+Search results can likewise be filtered by adding the `--filter-result` (or `-f`) option. Considering the node data above, you can use `knife search` with filtering to extract the c and ruby versions on your Ubuntu platforms:
+```bash
+$ knife search node "platform:ubuntu" --filter-result "c_version:languages.c.gcc.version, ruby_version:languages.ruby.version"
+1 items found
+
+:
+ c_version: 4.6.3
+ ruby_version: 1.9.3
+
+$
+```
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 30c5d0893e..f5a74d6a43 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -237,3 +237,9 @@ work properly if the remote server implemented only the Chef 10 API.
## CookbookSiteStreamingUploader now uses ssl_verify_mode config option
The CookbookSiteStreamingUploader now obeys the setting of ssl_verify_mode in the client config. Was previously ignoring the
config setting and always set to VERIFY_NONE.
+
+## Result filtering on `search` API.
+`search` can take an optional `:filter_result`, which returns search data in the form specified
+by the given Hash. This works analogously to the partial_search method from the [partial_search cookbook](https://supermarket.getchef.com/cookbooks/partial_search),
+with `:filter_result` replacing `:keys`. You can also filter `knife search` results by supplying the `--filter-result`
+or `-f` option and a comma-separated string representation of the filter hash.