Class: Itamae::Plugin::Resource::EncryptedRemoteFile

Inherits:
Resource::RemoteFile
  • Object
show all
Defined in:
lib/itamae/plugin/resource/encrypted_remote_file.rb

Instance Method Summary collapse

Instance Method Details

#action_create(options) ⇒ Object



28
29
30
31
32
# File 'lib/itamae/plugin/resource/encrypted_remote_file.rb', line 28

def action_create(options)
  super

  @decrypted_tempfile.close! if @decrypted_tempfile
end

#content_fileObject



24
25
26
# File 'lib/itamae/plugin/resource/encrypted_remote_file.rb', line 24

def content_file
  @decrypted_tempfile.path
end

#pre_actionObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/itamae/plugin/resource/encrypted_remote_file.rb', line 12

def pre_action
  encrypted_data = File.read(source_file).strip

  decrypted_data = ReversibleCryptography::Message.decrypt(encrypted_data, attributes.password)
  @decrypted_tempfile = Tempfile.open(File.basename(source_file)) do |f|
    f.write(decrypted_data)
    f
  end

  super
end