mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
add option :joyent_keydata. This allows the key to be read from a file outside of Fog and be passed into the initializer. This way the key data can be stored in something other than a file and still be used.
This commit is contained in:
parent
e70344cf94
commit
2150f32b74
1 changed files with 21 additions and 14 deletions
|
@ -13,6 +13,7 @@ module Fog
|
|||
|
||||
recognizes :joyent_keyname
|
||||
recognizes :joyent_keyfile
|
||||
recognizes :joyent_keydata
|
||||
recognizes :joyent_keyphrase
|
||||
recognizes :joyent_version
|
||||
|
||||
|
@ -115,24 +116,30 @@ module Fog
|
|||
raise ArgumentError, "options[:joyent_username] required"
|
||||
end
|
||||
|
||||
if options[:joyent_keyname] && options[:joyent_keyfile]
|
||||
if File.exists?(options[:joyent_keyfile])
|
||||
@joyent_keyname = options[:joyent_keyname]
|
||||
@joyent_keyfile = options[:joyent_keyfile]
|
||||
@joyent_keyphrase = options[:joyent_keyphrase]
|
||||
|
||||
@key_manager = Net::SSH::Authentication::KeyManager.new(nil, {
|
||||
if options[:joyent_keyname]
|
||||
@joyent_keyname = options[:joyent_keyname]
|
||||
@joyent_keyphrase = options[:joyent_keyphrase]
|
||||
@key_manager = Net::SSH::Authentication::KeyManager.new(nil, {
|
||||
:keys_only => true,
|
||||
:passphrase => @joyent_keyphrase
|
||||
})
|
||||
})
|
||||
@header_method = method(:header_for_signature_auth)
|
||||
|
||||
@key_manager.add(@joyent_keyfile)
|
||||
|
||||
@header_method = method(:header_for_signature_auth)
|
||||
else
|
||||
raise ArgumentError, "options[:joyent_keyfile] provided does not exist."
|
||||
if options[:joyent_keyfile]
|
||||
if File.exists?(options[:joyent_keyfile])
|
||||
@joyent_keyfile = options[:joyent_keyfile]
|
||||
@key_manager.add(@joyent_keyfile)
|
||||
else
|
||||
raise ArgumentError, "options[:joyent_keyfile] provided does not exist."
|
||||
end
|
||||
elsif options[:joyent_keydata]
|
||||
if options[:joyent_keydata].to_s.empty?
|
||||
raise ArgumentError, 'options[:joyent_keydata] must not be blank'
|
||||
else
|
||||
@joyent_keydata = options[:joyent_keydata]
|
||||
@key_manager.add_key_data(@joyent_keydata)
|
||||
end
|
||||
end
|
||||
|
||||
elsif options[:joyent_password]
|
||||
@joyent_password = options[:joyent_password]
|
||||
@header_method = method(:header_for_basic_auth)
|
||||
|
|
Loading…
Add table
Reference in a new issue