summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2018-02-22 08:45:59 +0000
committerGitHub <noreply@github.com>2018-02-22 08:45:59 +0000
commita6797d3ea413dc094f1f9439868269344d8c2a43 (patch)
tree159b563d582f8282d22d861a51ea9df65b645e37
parent6ff07ab5b10f56bebfa44a7a1e4dd07d9acb1ed3 (diff)
parent725558ddb688b9651ef759e704069094e88d4a9b (diff)
downloadchef-a6797d3ea413dc094f1f9439868269344d8c2a43.tar.gz
Merge pull request #6893 from chef/search_ids
Prevent knife search --id-only from outputting IDs in the same format as an empty hash
-rw-r--r--lib/chef/knife/search.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/chef/knife/search.rb b/lib/chef/knife/search.rb
index 2a68ec5108..94c33aa594 100644
--- a/lib/chef/knife/search.rb
+++ b/lib/chef/knife/search.rb
@@ -98,7 +98,9 @@ class Chef
begin
q.search(@type, @query, search_args) do |item|
formatted_item = Hash.new
- if item.is_a?(Hash)
+ if config[:id_only]
+ formatted_item = format_for_display({ "id" => item["__display_name"] })
+ elsif item.is_a?(Hash)
# doing a little magic here to set the correct name
formatted_item[item["__display_name"]] = item.reject { |k| k == "__display_name" }
else