Skip to content

Commit

Permalink
Revert "Remove option for not raising exceptions for now."
Browse files Browse the repository at this point in the history
This reverts commit 5e5ed91, putting
back the option to prevent exceptions from being raised.
  • Loading branch information
Magisus committed Nov 29, 2018
1 parent 9cc939b commit c060f7a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/puppet/functions/vault_lookup/lookup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@
dispatch :lookup do
param 'String', :path
optional_param 'String', :vault_url
optional_param 'Boolean', :raise_exceptions
end

def lookup(path, vault_url = nil)
def lookup(path, vault_url = nil, raise_exceptions = true)
_lookup(path, vault_url)
rescue StandardError => e
raise if raise_exceptions

Puppet.err(e.message)
nil
end

private

def _lookup(path, vault_url)
if vault_url.nil?
Puppet.debug 'No Vault address was set on function, defaulting to value from VAULT_ADDR env value'
vault_url = ENV['VAULT_ADDR']
Expand Down Expand Up @@ -37,8 +49,6 @@ def lookup(path, vault_url = nil)
Puppet::Pops::Types::PSensitiveType::Sensitive.new(data)
end

private

def get_auth_token(connection)
response = connection.post('/v1/auth/cert/login', '')
unless response.is_a?(Net::HTTPOK)
Expand Down

0 comments on commit c060f7a

Please sign in to comment.