Class: Ironclad::Source::OnePassword
- Inherits:
-
Object
- Object
- Ironclad::Source::OnePassword
- Defined in:
- lib/ironclad/source/one_password.rb
Overview
Reads a secret from 1Password via the ‘op` CLI.
Instance Method Summary collapse
-
#initialize(account = nil) ⇒ OnePassword
constructor
A new instance of OnePassword.
- #read(reference) ⇒ Object
Constructor Details
#initialize(account = nil) ⇒ OnePassword
Returns a new instance of OnePassword.
9 10 11 |
# File 'lib/ironclad/source/one_password.rb', line 9 def initialize(account = nil) @account = account end |
Instance Method Details
#read(reference) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ironclad/source/one_password.rb', line 13 def read(reference) cmd = ['op', 'read', reference] cmd.push('--account', @account) if @account out, err, status = Open3.capture3(*cmd) unless status.success? = 'Could not read the credentials key from 1Password. ' \ 'Authorize the prompt and retry, or run: op signin' detail = err.strip += " (#{detail})" unless detail.empty? raise Error, end out.chomp end |