188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
# File 'lib/chef/knife/knife-wip.rb', line 188
def run
q = Chef::Search::Query.new
query = URI.escape("tags:wip*", Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
result_items = []
result_count = 0
begin
q.search('node', query) do |item|
formatted_item = format_for_display(item)
result_items << formatted_item
result_count += 1
end
rescue Net::HTTPServerException => e
msg = Chef::JSONCompat.from_json(e.response.body)["error"].first
ui.error("knife wip list failed: #{msg}")
exit 1
end
if ui.interchange?
output({:results => result_count, :rows => result_items})
else
ui.msg "#{result_count} nodes found with work in progress"
ui.msg("\n")
result_items.each do |item|
normalized_tags = []
item.tags.each do |tag|
next unless tag.start_with? "wip:"
tag = tag.split(":")
normalized_tags << tag[1, tag.length].join(":")
end
output("#{item.name}: #{normalized_tags.join(", ")}")
end
end
end
|