diff --git a/lib/zanzibar.rb b/lib/zanzibar.rb index 2813bb6..1d7e6c5 100644 --- a/lib/zanzibar.rb +++ b/lib/zanzibar.rb @@ -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 diff --git a/lib/zanzibar/actions/get.rb b/lib/zanzibar/actions/get.rb index 3fd24c2..5683477 100644 --- a/lib/zanzibar/actions/get.rb +++ b/lib/zanzibar/actions/get.rb @@ -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