Class: Chef::Knife::DataBagInspect

Inherits:
Chef::Knife show all
Defined in:
lib/chef/knife/data_bag_inspect.rb

Instance Method Summary collapse

Instance Method Details

#runObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/chef/knife/data_bag_inspect.rb', line 9

def run
  case @name_args.length
  when 2 # We are inspecting a data bag item
    bag_name  = @name_args[0]
    item_name = @name_args[1]

    validator = ::HealthInspector::Checklists::DataBagItems.new(self)
    item = validator.load_item("#{bag_name}/#{item_name}")
    exit validator.validate_item item

  when 1 # We are inspecting a data bag
    bag_name = @name_args[0]

    validator = ::HealthInspector::Checklists::DataBags.new(self)
    item = validator.load_item(bag_name)
    exit validator.validate_item item

  when 0 # We are inspecting all the data bags
    exit ::HealthInspector::Checklists::DataBags.run(self) &&
         ::HealthInspector::Checklists::DataBagItems.run(self)
  end
end