mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
fix non-default credentials
This commit is contained in:
parent
1b161f4841
commit
16d68f96cd
2 changed files with 16 additions and 9 deletions
14
bin/fog
14
bin/fog
|
@ -5,8 +5,8 @@ require 'yaml'
|
|||
|
||||
module Fog
|
||||
module Credentials
|
||||
credential = (ARGV.first && :"#{ARGV.first}") || :default
|
||||
unless Fog.credentials[credential]
|
||||
Fog.credential = (ARGV.first && :"#{ARGV.first}") || :default
|
||||
unless Fog.credentials
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
@ -15,12 +15,11 @@ end
|
|||
module AWS
|
||||
class << self
|
||||
credential = (ARGV.first && :"#{ARGV.first}") || :default
|
||||
if Fog.credentials[credential][:aws_access_key_id] && Fog.credentials[credential][:aws_secret_access_key]
|
||||
if Fog.credentials[:aws_access_key_id] && Fog.credentials[:aws_secret_access_key]
|
||||
|
||||
def [](service)
|
||||
@@connections ||= Hash.new do |hash, key|
|
||||
credential = (ARGV.first && :"#{ARGV.first}") || :default
|
||||
credentials = Fog.credentials[credential].reject do |k, v|
|
||||
credentials = Fog.credentials.reject do |k, v|
|
||||
![:aws_access_key_id, :aws_secret_access_key].include?(k)
|
||||
end
|
||||
hash[key] = case key
|
||||
|
@ -75,13 +74,12 @@ end
|
|||
|
||||
module Rackspace
|
||||
class << self
|
||||
credential = (ARGV.first && :"#{ARGV.first}") || :default
|
||||
if Fog.credentials[credential][:rackspace_api_key] && Fog.credentials[credential][:rackspace_username]
|
||||
if Fog.credentials[:rackspace_api_key] && Fog.credentials[:rackspace_username]
|
||||
|
||||
def [](service)
|
||||
@@connections ||= Hash.new do |hash, key|
|
||||
credential = (ARGV.first && :"#{ARGV.first}") || :default
|
||||
credentials = Fog.credentials[credential].reject do |k,v|
|
||||
credentials = Fog.credentials.reject do |k,v|
|
||||
![:rackspace_api_key, :rackspace_username].include?(k)
|
||||
end
|
||||
hash[key] = case key
|
||||
|
|
11
lib/fog.rb
11
lib/fog.rb
|
@ -38,6 +38,15 @@ module Fog
|
|||
load "fog/slicehost.rb"
|
||||
end
|
||||
|
||||
def self.credential=(new_credential)
|
||||
@credential = new_credential
|
||||
@credentials = nil
|
||||
end
|
||||
|
||||
def self.credential
|
||||
@credential || :default
|
||||
end
|
||||
|
||||
def self.credentials
|
||||
@credentials ||= begin
|
||||
path = File.expand_path('~/.fog')
|
||||
|
@ -62,7 +71,7 @@ module Fog
|
|||
YML
|
||||
print(yml)
|
||||
end
|
||||
credentials
|
||||
credentials[credential]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue