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 28, 2018
1 parent 1ae0857 commit 6289aff
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
param 'String', :vault_url
optional_param 'Boolean', :raise_exceptions
end

def lookup(path, vault_url)
def lookup(path, vault_url, 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)
uri = URI(vault_url)
# URI is used here to just parse the vault_url into a host string
# and port; it's possible to generate a URI::Generic when a scheme
Expand All @@ -31,8 +43,6 @@ def lookup(path, vault_url)
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 6289aff

Please sign in to comment.