Class: HealthInspector::Checklists::DataBags

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

Instance Method Summary collapse

Methods inherited from Base

#all_item_names, #banner, #indent, #initialize, #load_ruby_or_json_from_local, #load_validate, option, #print_failures, #print_failures_from_hash, #print_key, #print_success, #print_value_diff, run, #run, title, #ui, underscored_class, #validate_item

Methods included from HealthInspector::Color

#color

Constructor Details

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

Instance Method Details

#load_item(name) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/health_inspector/checklists/data_bags.rb', line 10

def load_item(name)
  DataBag.new(@context,
              name: name,
              server: server_items.include?(name),
              local: local_items.include?(name)
  )
end

#local_itemsObject

JSON files are data bag items, their parent folder is the data bag



23
24
25
26
27
# File 'lib/health_inspector/checklists/data_bags.rb', line 23

def local_items
  @local_items ||= Dir["#{@context.repo_path}/data_bags/**/*.json"].map do |e|
    e.split('/')[-2].gsub('.json', '')
  end
end

#server_itemsObject



18
19
20
# File 'lib/health_inspector/checklists/data_bags.rb', line 18

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