Class: HealthInspector::Checklists::DataBags

Inherits:
Base
  • Object
show all
Defined in:
lib/health_inspector/checklists/data_bags.rb

Defined Under Namespace

Classes: DataBag

Instance Method Summary collapse

Methods inherited from Base

add_check, #banner, #checks, #chef_rest, #indent, #initialize, #load_ruby_or_json_from_local, #print_failures, #print_failures_from_hash, #print_key, #print_success, #print_value_diff, #run, run, #run_check, #run_checks

Methods included from HealthInspector::Color

#color

Constructor Details

This class inherits a constructor from HealthInspector::Checklists::Base

Instance Method Details

#data_bags_in_repoObject



38
39
40
41
42
# File 'lib/health_inspector/checklists/data_bags.rb', line 38

def data_bags_in_repo
  @data_bags_in_repo ||= Dir["#{@context.repo_path}/data_bags/*"].entries.
    select { |e| File.directory?(e) }.
    map { |e| File.basename(e) }
end

#data_bags_on_serverObject



34
35
36
# File 'lib/health_inspector/checklists/data_bags.rb', line 34

def data_bags_on_server
  @data_bags_on_server ||= Chef::DataBag.list.keys
end

#each_itemObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/health_inspector/checklists/data_bags.rb', line 18

def each_item
  server_data_bags   = data_bags_on_server
  local_data_bags    = data_bags_in_repo
  all_data_bag_names = ( server_data_bags + local_data_bags ).uniq.sort

  all_data_bag_names.each do |name|
    item = DataBag.new.tap do |data_bag|
      data_bag.name = name
      data_bag.exists_on_server = data_bags_on_server.include?(name)
      data_bag.exists_locally   = data_bags_in_repo.include?(name)
    end

    yield item
  end
end