Class: Chef::Knife::SecureBagEdit

Inherits:
Knife::DataBagEdit
  • Object
show all
Includes:
SecureBagBase
Defined in:
lib/chef/knife/secure_bag_edit.rb

Instance Method Summary collapse

Methods included from SecureBagBase

#data_for_create, #data_for_edit, #data_for_save, #encoded_fields, included, #read_secret, #require_secret, #secret_file, #use_encryption

Instance Method Details

#edit_item(item) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/chef/knife/secure_bag_edit.rb', line 23

def edit_item(item)
  output = super
  output = data_for_save(output)

  item = SecureDataBag::Item.from_hash(output, key:read_secret)
  item.encoded_fields encoded_fields
  item.to_hash encoded:true
end

#load_item(bag, item_name) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/chef/knife/secure_bag_edit.rb', line 13

def load_item(bag, item_name)
  item = Chef::DataBagItem.load(bag, item_name)
  @raw_data = item.to_hash

  item = SecureDataBag::Item.from_item(item, key:read_secret)
  hash = item.to_hash(encoded: false)
  hash = data_for_edit(hash)
  hash
end