summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/encrypted_data_bag_item.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/chef/encrypted_data_bag_item.rb b/lib/chef/encrypted_data_bag_item.rb
index b38a6f3512..65dfc3df9a 100644
--- a/lib/chef/encrypted_data_bag_item.rb
+++ b/lib/chef/encrypted_data_bag_item.rb
@@ -49,6 +49,22 @@ require 'open-uri'
class Chef::EncryptedDataBagItem
ALGORITHM = 'aes-256-cbc'
+ #
+ # === Synopsis
+ #
+ # EncryptedDataBagItem.new(hash, secret)
+ #
+ # === Args
+ #
+ # +enc_hash+::
+ # The encrypted hash to be decrypted
+ # +secret+::
+ # The raw secret key
+ #
+ # === Description
+ #
+ # Create a new encrypted data bag item for reading (decryption)
+ #
def initialize(enc_hash, secret)
@enc_hash = enc_hash
@secret = secret
@@ -82,6 +98,26 @@ class Chef::EncryptedDataBagItem
end
end
+ #
+ # === Synopsis
+ #
+ # EncryptedDataBagItem.load(data_bag, name, secret = nil)
+ #
+ # === Args
+ #
+ # +data_bag+::
+ # The name of the data bag to fetch
+ # +name+::
+ # The name of the data bag item to fetch
+ # +secret+::
+ # The raw secret key. If the +secret+ is nil, the value of the file at
+ # +Chef::Config[:encrypted_data_bag_secret]+ is loaded. See +load_secret+
+ # for more information.
+ #
+ # === Description
+ #
+ # Loads and decrypts the data bag item with the given name.
+ #
def self.load(data_bag, name, secret = nil)
raw_hash = Chef::DataBagItem.load(data_bag, name)
secret = secret || self.load_secret