Class: Chef::Knife::SavedSearchUpdate

Inherits:
Chef::Knife show all
Includes:
SavedSearchBase
Defined in:
lib/chef/knife/saved_search_update.rb

Instance Method Summary collapse

Methods included from SavedSearchBase

#data_bag, included

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/chef/knife/saved_search_update.rb', line 11

def run
  if name_args.length < 3 || name_args.length > 4
    show_usage
    ui.fatal("You must specify a saved search name, index, and query, with an optional description")
    exit 1
  end

  name, index, query, description = name_args

  item = Chef::DataBagItem.load(data_bag, name)
  item["index"] = index
  item["query"] = query
  item["description"] = description if description
  item.save
  msg "Updated saved_search[#{name}]"
end