Set and use fieldlabel value in zanzibar_options instead

This commit is contained in:
Calvin Leung Huang
2016-04-14 13:29:43 -04:00
parent ca55a4de57
commit 561a523261
2 changed files with 9 additions and 8 deletions

View File

@@ -127,7 +127,7 @@ module Zanzibar
end
## Retrieve a simple password from a secret
# Calls get get_fieldlabel_value(), passing in 'Password' as the fieldlabel
# Calls get get_fieldlabel_value()
# @param [Integer] the secret id
# @return [String] the password for the given secret

View File

@@ -20,20 +20,19 @@ module Zanzibar
construct_options
ensure_options
fetch_secret(@scrt_id, options)
fetch_secret(@scrt_id)
end
def fetch_secret(scrt_id, opts = nil)
def fetch_secret(scrt_id)
scrt = ::Zanzibar::Zanzibar.new(@zanzibar_options)
if opts['filelabel']
if @zanzibar_options[:filelabel]
scrt.download_secret_file(scrt_id: scrt_id,
type: opts['filelabel'])
elsif opts['fieldlabel']
scrt.get_fieldlabel_value(scrt_id, opts['fieldlabel'])
type: @zanzibar_options[:filelabel])
else
scrt.get_password(scrt_id)
scrt.get_fieldlabel_value(scrt_id, @zanzibar_options[:fieldlabel])
end
end
def construct_options
@@ -42,6 +41,8 @@ module Zanzibar
@zanzibar_options[:domain] = options['domain']
@zanzibar_options[:username] = options['username'] unless options['username'].nil?
@zanzibar_options[:domain] = options['domain'] ? options['domain'] : 'local'
@zanzibar_options[:fieldlabel] = options['fieldlabel'] || 'Password'
@zanzibar_options[:filelabel] = options['filelabel'] if options['filelabel']
end
def construct_wsdl