Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Sep 27, 2014
1 parent db8a20f commit a68d426
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions libraries/chef_nexus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,16 @@ def encrypted_data_bag_for(node, data_bag)

def encrypted_data_bag_item(node, data_bag, data_bag_item)
if node[:nexus][:use_chef_vault]
item = ChefVault::Item.load(data_bag, data_bag_item)
begin
item = ChefVault::Item.load(data_bag, data_bag_item)
# if you are using vault and if data bag it not present we need to handle that exception as well
rescue ChefVault::Exceptions::KeysNotFound
nil
end
else
p data_bag
p data_bag_item
p node
item = Chef::EncryptedDataBagItem.load(data_bag, data_bag_item)
end
Mash.from_hash(item.to_hash)
Expand All @@ -226,10 +234,6 @@ def encrypted_data_bag_item(node, data_bag, data_bag_item)
# Adding a different rescue block if things exception needs to be handled differently
rescue Chef::Exceptions::ValidationFailed => e
nil

# if you are using vault and if data bag it not present we need to handle that exception as well
rescue ChefVault::Exceptions::KeysNotFound
nil
end
end
end
Expand Down

0 comments on commit a68d426

Please sign in to comment.