Last active
August 29, 2015 13:56
-
-
Save afirth/8829468 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.load(data_bag, name, secret = nil) #secret can be nil | |
raw_hash = Chef::DataBagItem.load(data_bag, name) #load the raw (encrypted) hash into a databag object | |
secret = secret || self.load_secret #if secret is specified, this or operator short circuits and returns the first value. if secret is nil, calls self.load secret (L7) | |
self.new(raw_hash, secret) #return a new object | |
end | |
def self.load_secret(path=nil) #again, path can be nil | |
path ||= Chef::Config[:encrypted_data_bag_secret] # a shortcut to saying path = path || Chef::Config... as L3 | |
if !path #nothing in path, means the default secret location wasn't set either. are you seeing this error? | |
raise ArgumentError, "No secret specified to load_secret and no secret found at #{Chef::Config.platform_specific_path('/etc/chef/encrypted_data_bag_secret')}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment