Class: Chef::Knife::DataBagFromFile

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/knife/chop/data_bag_from_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv = []) ⇒ DataBagFromFile


Create a new instance of the current class configured for the given arguments and options



12
13
14
15
16
# File 'lib/chef/knife/chop/data_bag_from_file.rb', line 12

def initialize(argv=[])
  super(argv)
  @rsrctype = 'databag'
  @location = 'data_bags'
end

Instance Method Details

#load_data_bag_items(data_bag, items = nil) ⇒ Object

DLDInternet monkey patch of original



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/chef/knife/chop/data_bag_from_file.rb', line 20

def load_data_bag_items(data_bag, items = nil)
  items ||= find_all_data_bag_items(data_bag)
  item_paths = normalize_item_paths(items)
  item_paths.each do |item_path|
    item = loader.load_from("#{data_bags_path}", data_bag, item_path)
    item = if use_encryption
             secret = read_secret
             Chef::EncryptedDataBagItem.encrypt_data_bag_item(item, secret)
           else
             item
           end
    dbag = Chef::DataBagItem.new
    dbag.data_bag(data_bag)
    dbag.raw_data = item
    dbag.save
    # BEGIN changes DLDInternet
    ui.info("Updated data_bag_item[#{dbag.data_bag}::#{dbag.id}]")
    # END changes DLDInternet
  end

end