Skip to content

Commit

Permalink
Deprecate wrong provider names
Browse files Browse the repository at this point in the history
  • Loading branch information
plribeiro3000 committed Apr 2, 2018
1 parent d7ff1c1 commit 3a13d5a
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 122 deletions.
16 changes: 0 additions & 16 deletions lib/fog/account.rb
@@ -1,21 +1,5 @@
module Fog
module Account
extend Fog::ServicesMixin

def self.new(orig_attributes)
attributes = orig_attributes.dup
provider = attributes.delete(:provider).to_s.downcase.to_sym

if provider == :stormondemand
require "fog/account/storm_on_demand"
Fog::Account::StormOnDemand.new(attributes)
else
super(orig_attributes)
end
end

def self.providers
Fog.services[:account] || []
end
end
end
11 changes: 0 additions & 11 deletions lib/fog/billing.rb
@@ -1,16 +1,5 @@
module Fog
module Billing
extend Fog::ServicesMixin

def self.new(orig_attributes)
attributes = orig_attributes.dup
provider = attributes.delete(:provider).to_s.downcase.to_sym
if provider == :stormondemand
require "fog/billing/storm_on_demand"
Fog::Billing::StormOnDemand.new(attributes)
else
super(orig_attributes)
end
end
end
end
22 changes: 0 additions & 22 deletions lib/fog/compute.rb
Expand Up @@ -7,16 +7,6 @@ def self.new(orig_attributes)
provider = attributes.delete(:provider).to_s.downcase.to_sym

case provider
when :gogrid
require "fog/go_grid/compute"
Fog::Compute::GoGrid.new(attributes)
when :new_servers
require "fog/bare_metal_cloud/compute"
Fog::Logger.deprecation "`new_servers` is deprecated. Please use `bare_metal_cloud` instead."
Fog::Compute::BareMetalCloud.new(attributes)
when :baremetalcloud
require "fog/bare_metal_cloud/compute"
Fog::Compute::BareMetalCloud.new(attributes)
when :rackspace
version = attributes.delete(:version)
version = version.to_s.downcase.to_sym unless version.nil?
Expand All @@ -38,18 +28,6 @@ def self.new(orig_attributes)
require 'fog/digitalocean/compute'
Fog::Compute::DigitalOcean.new(attributes)
end
when :stormondemand
require "fog/compute/storm_on_demand"
Fog::Compute::StormOnDemand.new(attributes)
when :vcloud
require "fog/vcloud/compute"
Fog::Vcloud::Compute.new(attributes)
when :vclouddirector
require "fog/vcloud_director/compute"
Fog::Compute::VcloudDirector.new(attributes)
when :cloudatcost
require "fog/cloudatcost/compute"
Fog::Compute::CloudAtCost.new(attributes)
else
super(orig_attributes)
end
Expand Down
26 changes: 25 additions & 1 deletion lib/fog/core/services_mixin.rb
Expand Up @@ -6,7 +6,7 @@ def [](provider)

def new(attributes)
attributes = attributes.dup # Prevent delete from having side effects
provider = attributes.delete(:provider).to_s.downcase.to_sym
provider = check_provider_alias(attributes.delete(:provider).to_s.downcase.to_sym)
provider_name = Fog.providers[provider]

raise ArgumentError, "#{provider} is not a recognized provider" unless providers.include?(provider)
Expand Down Expand Up @@ -43,5 +43,29 @@ def const_get_args(*args)
def service_name
name.split("Fog::").last
end

def check_provider_alias(provider)
case provider
when :baremetalcloud
Fog::Logger.deprecation(':baremetalcloud is deprecated. Use :bare_metal_cloud instead!')
:bare_metal_cloud
when :gogrid
Fog::Logger.deprecation(':gogrid is deprecated. Use :go_grid instead!')
:go_grid
when :internetarchive
Fog::Logger.deprecation(':internetarchive is deprecated. Use :internet_archive instead!')
:internet_archive
when :new_servers
Fog::Logger.deprecation(':new_servers is deprecated. Use :bare_metal_cloud instead!')
:bare_metal_cloud
when :stormondemand
Fog::Logger.deprecation(':stormondemand is deprecated. Use :storm_on_demand instead!')
:storm_on_demand
when :vclouddirector
Fog::Logger.deprecation(':vclouddirector is deprecated. Use :vcloud_director instead!')
:vcloud_director
else provider
end
end
end
end
11 changes: 0 additions & 11 deletions lib/fog/dns.rb
Expand Up @@ -2,17 +2,6 @@ module Fog
module DNS
extend Fog::ServicesMixin

def self.new(orig_attributes)
attributes = orig_attributes.dup # prevent delete from having side effects
case attributes.delete(:provider).to_s.downcase.to_sym
when :stormondemand
require "fog/dns/storm_on_demand"
Fog::DNS::StormOnDemand.new(attributes)
else
super(orig_attributes)
end
end

def self.zones
zones = []
providers.each do |provider|
Expand Down
11 changes: 0 additions & 11 deletions lib/fog/monitoring.rb
@@ -1,16 +1,5 @@
module Fog
module Monitoring
extend Fog::ServicesMixin

def self.new(orig_attributes)
attributes = orig_attributes.dup
provider = attributes.delete(:provider).to_s.downcase.to_sym
if provider == :stormondemand
require "fog/monitoring/storm_on_demand"
Fog::Monitoring::StormOnDemand.new(attributes)
else
super(orig_attributes)
end
end
end
end
12 changes: 0 additions & 12 deletions lib/fog/network.rb
@@ -1,17 +1,5 @@
module Fog
module Network
extend Fog::ServicesMixin

def self.new(orig_attributes)
attributes = orig_attributes.dup # Prevent delete from having side effects
provider = attributes.delete(:provider).to_s.downcase.to_sym

if provider == :stormondemand
require "fog/network/storm_on_demand"
return Fog::Network::StormOnDemand.new(attributes)
else
super(orig_attributes)
end
end
end
end
14 changes: 0 additions & 14 deletions lib/fog/storage.rb
Expand Up @@ -9,20 +9,6 @@ module Fog
module Storage
extend Fog::ServicesMixin

def self.new(orig_attributes)
attributes = orig_attributes.dup # prevent delete from having side effects
case attributes.delete(:provider).to_s.downcase.to_sym
when :internetarchive
require "fog/internet_archive/storage"
Fog::Storage::InternetArchive.new(attributes)
when :stormondemand
require "fog/storage/storm_on_demand"
Fog::Storage::StormOnDemand.new(attributes)
else
super(orig_attributes)
end
end

def self.directories
directories = []
providers.each do |provider|
Expand Down
12 changes: 0 additions & 12 deletions lib/fog/support.rb
@@ -1,17 +1,5 @@
module Fog
module Support
extend Fog::ServicesMixin

def self.new(orig_attributes)
attributes = orig_attributes.dup
provider = attributes.delete(:provider).to_s.downcase.to_sym

if provider == :stormondemand
require "fog/support/storm_on_demand"
Fog::Support::StormOnDemand.new(attributes)
else
super(orig_attributes)
end
end
end
end
12 changes: 0 additions & 12 deletions lib/fog/vpn.rb
@@ -1,17 +1,5 @@
module Fog
module VPN
extend Fog::ServicesMixin

def self.new(orig_attributes)
attributes = orig_attributes.dup
provider = attributes.delete(:provider).to_s.downcase.to_sym

if provider == :stormondemand
require "fog/vpn/storm_on_demand"
Fog::VPN::StormOnDemand.new(attributes)
else
super(orig_attributes)
end
end
end
end

0 comments on commit 3a13d5a

Please sign in to comment.