Method: Arcanus.load
- Defined in:
- lib/arcanus.rb
.load(directory = Dir.pwd) ⇒ Object
Loads Arcanus chest and decrypts secrets.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/arcanus.rb', line 30 def load(directory = Dir.pwd) @config = Configuration.load_applicable(directory) @repo = Repo.new(@config) unless File.directory?(@repo.arcanus_dir) raise Errors::UsageError, 'Arcanus has not been initialized in this repository. ' \ 'Run `arcanus setup`' end if File.exist?(@repo.unlocked_key_path) key = Arcanus::Key.from_file(@repo.locked_key_path) elsif ENV['ARCANUS_PASSWORD'] key = Arcanus::Key.from_protected_file(@repo.locked_key_path, ENV['ARCANUS_PASSWORD']) ENV.delete('ARCANUS_PASSWORD') # Scrub so child processes don't inherit else raise Errors::UsageError, 'Arcanus key has not been unlocked. ' \ 'Run `arcanus unlock` or specify password via ARCANUS_PASSWORD environment variable' end @chest = Chest.new(key: key, chest_file_path: @repo.chest_file_path) end |