Module: Balmora::Extension::FileSecret

Defined in:
lib/balmora/extension/file_secret.rb

Instance Method Summary collapse

Instance Method Details

#_copy_fileObject



7
8
9
10
11
12
13
14
15
# File 'lib/balmora/extension/file_secret.rb', line 7

def _copy_file()
  if @action == 'pull'
    @shell.run!(_source_contents() + [_expr('|'), *@shell.sudo(), 'tee',
      _target_path()], change: true)
  else
    @shell.run!(['cat', _source_path(), _expr('|'), *_encrypt(), _expr('|'),
      *@shell.sudo(), 'tee', _target_path()], change: true)
  end
end

#_decryptObject



37
38
39
# File 'lib/balmora/extension/file_secret.rb', line 37

def _decrypt()
  return ['openssl', 'enc', '-aes-256-cbc', '-d', '-pass', option(:password)]
end

#_encryptObject



41
42
43
# File 'lib/balmora/extension/file_secret.rb', line 41

def _encrypt()
  return ['openssl', 'enc', '-aes-256-cbc', '-e', '-pass', option(:password)]
end

#_source_contentsObject



17
18
19
20
21
22
23
24
25
# File 'lib/balmora/extension/file_secret.rb', line 17

def _source_contents()
  command = super()

  if @action == 'pull'
    command += [_expr('|')] + _decrypt()
  end

  return command
end

#_target_contentsObject



27
28
29
30
31
32
33
34
35
# File 'lib/balmora/extension/file_secret.rb', line 27

def _target_contents()
  command = super()

  if @action == 'push'
    command += [_expr('|')] + _decrypt()
  end

  return command
end

#optionsObject



3
4
5
# File 'lib/balmora/extension/file_secret.rb', line 3

def options()
  return super() + [:password]
end