Class: Bora::Resolver::Credstash

Inherits:
Object
  • Object
show all
Defined in:
lib/bora/resolver/credstash.rb

Constant Summary collapse

InvalidParameter =
Class.new(StandardError)

Instance Method Summary collapse

Constructor Details

#initialize(stack) ⇒ Credstash

Returns a new instance of Credstash.



10
11
12
# File 'lib/bora/resolver/credstash.rb', line 10

def initialize(stack)
  @stack = stack
end

Instance Method Details

#resolve(uri) ⇒ Object

Raises:



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bora/resolver/credstash.rb', line 14

def resolve(uri)
  raise InvalidParameter, "Invalid credstash parameter #{uri}: no credstash key" unless uri.path
  key = uri.path[1..-1]
  raise InvalidParameter, "Invalid credstash parameter #{uri}: no credstash key" if !key || key.empty?
  region = resolve_region(uri, @stack)
  context = parse_key_context(uri)
  output = `credstash --region #{region} get #{key}#{context}`
  # exit_code = $?
  raise NotFound, output unless $CHILD_STATUS.success?
  output.rstrip
end