Class: SecretBroker::EJsonSecretsFile

Inherits:
Object
  • Object
show all
Defined in:
lib/secret_broker/ejson_secrets_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ EJsonSecretsFile

Returns a new instance of EJsonSecretsFile.



6
7
8
# File 'lib/secret_broker/ejson_secrets_file.rb', line 6

def initialize(env)
  @env = env
end

Instance Method Details

#to_hObject



10
11
12
13
14
15
16
17
# File 'lib/secret_broker/ejson_secrets_file.rb', line 10

def to_h
  return {} unless file_path.file?

  stdout_str, stderr_str, status = Open3.capture3 "ejson decrypt #{file_path.to_path}"
  fail "ejson decrypt did not run successfully. stderr: #{stderr_str}" unless status.success?

  JSON.parse stdout_str
end