Class: Chef::Knife::BriefcaseGet
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::BriefcaseGet
- Includes:
- KnifeBriefcase::Knife
- Defined in:
- lib/chef/knife/briefcase_get.rb
Instance Method Summary collapse
Methods included from KnifeBriefcase::Knife
#data_bag_name, deps, #file, #highline, inherited, #item_name, #recipients, #signers
Instance Method Details
#run ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/chef/knife/briefcase_get.rb', line 7 def run encrypted = Chef::DataBagItem.load(data_bag_name, @name_args[0]). raw_data['content'] begin crypto.verify(GPGME::Data.from_str(encrypted)) do |sig| if sig.valid? Chef::Log.info(sig.to_s) else Chef::Log.error(sig.to_s) exit 1 # TODO: --force end end rescue Chef::Log.error("Cannot verify signature: #{$!}") exit 1 end if file crypto.decrypt(GPGME::Data.from_str(encrypted), :output => File.open(file, 'w+')) else stdout.write(crypto.decrypt(GPGME::Data.from_str(encrypted))) end rescue GPGME::Error::DecryptFailed Chef::Log.fatal("Decryption failed") exit 1 end |