1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

consolidate credential management when running from bin

This commit is contained in:
geemus 2010-09-02 13:39:01 -07:00
parent a16e334224
commit c96614a11d
12 changed files with 28 additions and 38 deletions

View file

@ -3,7 +3,8 @@ require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
require 'irb'
require 'yaml'
require File.join('fog', 'credentials')
Fog.credential = ARGV.first ? :"#{ARGV.first}" : :default
Fog.credential = ARGV.first
Fog.bin = true
unless Fog.credentials
exit
end

View file

@ -61,6 +61,14 @@ module Fog
end
def self.bin
@bin ||= false
end
def self.bin=(new_bin)
@bin = new_bin
end
def self.mock!
@mocking = true
end

View file

@ -9,18 +9,15 @@ module AWS
def [](service)
@@connections ||= Hash.new do |hash, key|
credentials = Fog.credentials.reject do |k, v|
![:aws_access_key_id, :aws_secret_access_key].include?(k)
end
hash[key] = case key
when :ec2
Fog::AWS::EC2.new(credentials)
Fog::AWS::EC2.new
when :elb
Fog::AWS::ELB.new(credentials)
Fog::AWS::ELB.new
when :simpledb
Fog::AWS::SimpleDB.new(credentials)
Fog::AWS::SimpleDB.new
when :s3
Fog::AWS::S3.new(credentials)
Fog::AWS::S3.new
end
end
@@connections[service]

View file

@ -1,4 +1,4 @@
module Fog
module Fog
module AWS
module EC2
extend Fog::Service

View file

@ -9,12 +9,9 @@ module Bluebox
def [](service)
@@connections ||= Hash.new do |hash, key|
credentials = Fog.credentials.reject do |k,v|
![:bluebox_api_key, :bluebox_customer_id].include?(k)
end
hash[key] = case key
when :blocks
Fog::Bluebox.new(credentials)
Fog::Bluebox.new
end
end
@@connections[service]

View file

@ -8,12 +8,9 @@ module GoGrid
def [](service)
@@connections ||= Hash.new do |hash, key|
credentials = Fog.credentials.reject do |k,v|
![:go_grid_api_key, :go_grid_shared_secret].include?(k)
end
hash[key] = case key
when :go_grid
Fog::GoGrid.new(credentials)
Fog::GoGrid.new
end
end
@@connections[service]

View file

@ -8,12 +8,9 @@ module Linode
def [](service)
@@connections ||= Hash.new do |hash, key|
credentials = Fog.credentials.reject do |k,v|
![:linode_api_key].include?(k)
end
hash[key] = case key
when :linode
Fog::Linode.new(credentials)
Fog::Linode.new
end
end
@@connections[service]

View file

@ -8,12 +8,9 @@ module Local
def [](service)
@@connections ||= Hash.new do |hash, key|
credentials = Fog.credentials.reject do |k,v|
![:local_root].include?(k)
end
hash[key] = case key
when :files
Fog::Local.new(credentials)
Fog::Local.new
end
end
@@connections[service]

View file

@ -8,12 +8,9 @@ module NewServers
def [](service)
@@connections ||= Hash.new do |hash, key|
credentials = Fog.credentials.reject do |k,v|
![:new_servers_password, :new_servers_username].include?(k)
end
hash[key] = case key
when :new_servers
Fog::NewServers.new(credentials)
Fog::NewServers.new
end
end
@@connections[service]

View file

@ -8,14 +8,11 @@ module Rackspace
def [](service)
@@connections ||= Hash.new do |hash, key|
credentials = Fog.credentials.reject do |k,v|
![:rackspace_api_key, :rackspace_username].include?(k)
end
hash[key] = case key
when :files
Fog::Rackspace::Files.new(credentials)
Fog::Rackspace::Files.new
when :servers
Fog::Rackspace::Servers.new(credentials)
Fog::Rackspace::Servers.new
end
end
@@connections[service]

View file

@ -10,6 +10,11 @@ module Fog
module Collections; end
def self.new(options={})
if Fog.bin
default_credentials = Fog.credentials.reject {|key, value| !requirements.include?(key)}
options = default_credentials.merge(options)
end
missing = []
for requirement in requirements
missing << requirement unless options[requirement]

View file

@ -8,12 +8,9 @@ module Slicehost
def [](service)
@@connections ||= Hash.new do |hash, key|
credentials = Fog.credentials.reject do |k,v|
![:slicehost_password].include?(k)
end
hash[key] = case key
when :slices
Fog::Slicehost.new(credentials)
Fog::Slicehost.new
end
end
@@connections[service]