fog-core 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/dependabot.yml +10 -0
- data/.github/workflows/ruby.yml +18 -0
- data/.github/workflows/stale.yml +9 -0
- data/CONTRIBUTING.md +5 -1
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/changelog.md +210 -141
- data/fog-core.gemspec +2 -2
- data/lib/fog/account.rb +0 -16
- data/lib/fog/billing.rb +0 -11
- data/lib/fog/compute.rb +0 -22
- data/lib/fog/core/attributes.rb +14 -2
- data/lib/fog/core/connection.rb +3 -5
- data/lib/fog/core/logger.rb +3 -0
- data/lib/fog/core/provider.rb +37 -4
- data/lib/fog/core/scp.rb +2 -1
- data/lib/fog/core/services_mixin.rb +61 -9
- data/lib/fog/core/ssh.rb +47 -24
- data/lib/fog/core/version.rb +1 -1
- data/lib/fog/dns.rb +0 -11
- data/lib/fog/monitoring.rb +0 -11
- data/lib/fog/network.rb +0 -12
- data/lib/fog/storage.rb +0 -14
- data/lib/fog/support.rb +0 -12
- data/lib/fog/test_helpers/succeeds_helper.rb +2 -2
- data/lib/fog/vpn.rb +0 -12
- data/spec/compute_spec.rb +27 -27
- data/spec/core/cache_spec.rb +1 -1
- data/spec/identity_spec.rb +28 -28
- data/spec/storage_spec.rb +29 -31
- metadata +19 -12
- data/.travis.yml +0 -39
data/lib/fog/compute.rb
CHANGED
@@ -7,16 +7,6 @@ module Fog
|
|
7
7
|
provider = attributes.delete(:provider).to_s.downcase.to_sym
|
8
8
|
|
9
9
|
case provider
|
10
|
-
when :gogrid
|
11
|
-
require "fog/go_grid/compute"
|
12
|
-
Fog::Compute::GoGrid.new(attributes)
|
13
|
-
when :new_servers
|
14
|
-
require "fog/bare_metal_cloud/compute"
|
15
|
-
Fog::Logger.deprecation "`new_servers` is deprecated. Please use `bare_metal_cloud` instead."
|
16
|
-
Fog::Compute::BareMetalCloud.new(attributes)
|
17
|
-
when :baremetalcloud
|
18
|
-
require "fog/bare_metal_cloud/compute"
|
19
|
-
Fog::Compute::BareMetalCloud.new(attributes)
|
20
10
|
when :rackspace
|
21
11
|
version = attributes.delete(:version)
|
22
12
|
version = version.to_s.downcase.to_sym unless version.nil?
|
@@ -38,18 +28,6 @@ module Fog
|
|
38
28
|
require 'fog/digitalocean/compute'
|
39
29
|
Fog::Compute::DigitalOcean.new(attributes)
|
40
30
|
end
|
41
|
-
when :stormondemand
|
42
|
-
require "fog/compute/storm_on_demand"
|
43
|
-
Fog::Compute::StormOnDemand.new(attributes)
|
44
|
-
when :vcloud
|
45
|
-
require "fog/vcloud/compute"
|
46
|
-
Fog::Vcloud::Compute.new(attributes)
|
47
|
-
when :vclouddirector
|
48
|
-
require "fog/vcloud_director/compute"
|
49
|
-
Fog::Compute::VcloudDirector.new(attributes)
|
50
|
-
when :cloudatcost
|
51
|
-
require "fog/cloudatcost/compute"
|
52
|
-
Fog::Compute::CloudAtCost.new(attributes)
|
53
31
|
else
|
54
32
|
super(orig_attributes)
|
55
33
|
end
|
data/lib/fog/core/attributes.rb
CHANGED
@@ -79,14 +79,26 @@ module Fog
|
|
79
79
|
|
80
80
|
def all_attributes
|
81
81
|
self.class.attributes.reduce({}) do |hash, attribute|
|
82
|
-
|
82
|
+
if masks[attribute].nil?
|
83
|
+
Fog::Logger.deprecation("Please define #{attribute} using the Fog DSL")
|
84
|
+
hash[attribute] = send(attribute)
|
85
|
+
else
|
86
|
+
hash[masks[attribute]] = send(attribute)
|
87
|
+
end
|
88
|
+
|
83
89
|
hash
|
84
90
|
end
|
85
91
|
end
|
86
92
|
|
87
93
|
def all_associations
|
88
94
|
self.class.associations.keys.reduce({}) do |hash, association|
|
89
|
-
|
95
|
+
if masks[association].nil?
|
96
|
+
Fog::Logger.deprecation("Please define #{association} using the Fog DSL")
|
97
|
+
hash[association] = associations[association] || send(association)
|
98
|
+
else
|
99
|
+
hash[masks[association]] = associations[association] || send(association)
|
100
|
+
end
|
101
|
+
|
90
102
|
hash
|
91
103
|
end
|
92
104
|
end
|
data/lib/fog/core/connection.rb
CHANGED
@@ -44,12 +44,10 @@ module Fog
|
|
44
44
|
# @option params [Class] :instrumentor Responds to #instrument as in ActiveSupport::Notifications
|
45
45
|
# @option params [String] :instrumentor_name Name prefix for #instrument events. Defaults to 'excon'
|
46
46
|
def initialize(url, persistent = false, params = {})
|
47
|
-
|
48
|
-
if params[:path]
|
49
|
-
raise ArgumentError, "optional arg 'path' is invalid when 'path_prefix' is provided"
|
50
|
-
end
|
47
|
+
@path_prefix = params.delete(:path_prefix)
|
51
48
|
|
52
|
-
|
49
|
+
if @path_prefix && params[:path]
|
50
|
+
raise ArgumentError, "optional arg 'path' is invalid when 'path_prefix' is provided"
|
53
51
|
end
|
54
52
|
|
55
53
|
params[:debug_response] = true unless params.key?(:debug_response)
|
data/lib/fog/core/logger.rb
CHANGED
data/lib/fog/core/provider.rb
CHANGED
@@ -8,9 +8,22 @@ module Fog
|
|
8
8
|
end
|
9
9
|
|
10
10
|
module Provider
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
class << self
|
12
|
+
def extended(base)
|
13
|
+
provider = base.to_s.split("::").last
|
14
|
+
Fog.providers[provider.downcase.to_sym] = provider
|
15
|
+
Fog.providers[underscore_name(provider).to_sym] = provider
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def underscore_name(string)
|
21
|
+
string.gsub(/::/, '/').
|
22
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
23
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
24
|
+
tr("-", "_").
|
25
|
+
downcase
|
26
|
+
end
|
14
27
|
end
|
15
28
|
|
16
29
|
def [](service_key)
|
@@ -21,11 +34,31 @@ module Fog
|
|
21
34
|
Fog.services[new_service] ||= []
|
22
35
|
Fog.services[new_service] |= [to_s.split("::").last.downcase.to_sym]
|
23
36
|
@services_registry ||= {}
|
24
|
-
@services_registry[new_service] =
|
37
|
+
@services_registry[new_service] = service_klass(constant_string)
|
25
38
|
end
|
26
39
|
|
27
40
|
def services
|
28
41
|
@services_registry.keys
|
29
42
|
end
|
43
|
+
|
44
|
+
# Returns service constant path, with provider, as string. If
|
45
|
+
# "provider::service" is defined (the preferred format) then it returns that
|
46
|
+
# string, otherwise it returns the deprecated string "service::provider".
|
47
|
+
def service_klass(constant_string)
|
48
|
+
if const_defined?([to_s, constant_string].join("::"))
|
49
|
+
[to_s, constant_string].join("::")
|
50
|
+
else
|
51
|
+
provider = to_s.split("::").last
|
52
|
+
Fog::Logger.deprecation("Unable to load #{[to_s, constant_string].join("::")}")
|
53
|
+
Fog::Logger.deprecation(
|
54
|
+
format(
|
55
|
+
Fog::ServicesMixin::E_SERVICE_PROVIDER_CONSTANT,
|
56
|
+
service: constant_string,
|
57
|
+
provider: provider
|
58
|
+
)
|
59
|
+
)
|
60
|
+
['Fog', constant_string, provider].join("::")
|
61
|
+
end
|
62
|
+
end
|
30
63
|
end
|
31
64
|
end
|
data/lib/fog/core/scp.rb
CHANGED
@@ -64,8 +64,9 @@ module Fog
|
|
64
64
|
|
65
65
|
@address = address
|
66
66
|
@username = username
|
67
|
-
@options = { :paranoid => false, :verify_host_key =>
|
67
|
+
@options = { :paranoid => false, :verify_host_key => :never }.merge(options)
|
68
68
|
@options.delete(:paranoid) if Net::SSH::VALID_OPTIONS.include? :verify_host_key
|
69
|
+
@options[:verify_host_key] = false unless Net::SSH::Verifiers.const_defined?(:Never)
|
69
70
|
end
|
70
71
|
|
71
72
|
def upload(local_path, remote_path, upload_options = {}, &block)
|
@@ -1,21 +1,37 @@
|
|
1
1
|
module Fog
|
2
2
|
module ServicesMixin
|
3
|
+
E_SERVICE_PROVIDER_CONSTANT = <<-EOS.gsub(/\s+/, ' ').strip.freeze
|
4
|
+
Falling back to deprecated constant Fog::%<service>s::%<provider>s. The
|
5
|
+
preferred format of service provider constants has changed from
|
6
|
+
service::provider to provider::service. Please update this service
|
7
|
+
provider to use the preferred format.
|
8
|
+
EOS
|
9
|
+
E_SERVICE_PROVIDER_PATH = <<-EOS.gsub(/\s+/, ' ').strip.freeze
|
10
|
+
Falling back to deprecated path fog/%<service>s/%<provider>s. The
|
11
|
+
preferred file path format has changed from service/provider to
|
12
|
+
provider/service. Please update this service provider to use the preferred
|
13
|
+
format.
|
14
|
+
EOS
|
15
|
+
|
3
16
|
def [](provider)
|
4
17
|
new(:provider => provider)
|
5
18
|
end
|
6
19
|
|
7
20
|
def new(attributes)
|
8
|
-
attributes
|
9
|
-
provider
|
10
|
-
|
21
|
+
attributes = attributes.dup # Prevent delete from having side effects
|
22
|
+
provider = attributes.delete(:provider).to_s.downcase.to_sym
|
23
|
+
provider_alias = check_provider_alias(provider)
|
24
|
+
provider_name = Fog.providers[provider_alias]
|
11
25
|
|
12
|
-
raise ArgumentError, "#{
|
26
|
+
raise ArgumentError, "#{provider_alias} is not a recognized provider" unless providers.include?(provider) || providers.include?(provider_alias)
|
13
27
|
|
14
|
-
require_service_provider_library(service_name.downcase,
|
28
|
+
require_service_provider_library(service_name.downcase, provider_alias)
|
15
29
|
spc = service_provider_constant(service_name, provider_name)
|
16
30
|
spc.new(attributes)
|
17
|
-
rescue LoadError, NameError # Only rescue errors in finding the libraries, allow connection errors through to the caller
|
18
|
-
|
31
|
+
rescue LoadError, NameError => e # Only rescue errors in finding the libraries, allow connection errors through to the caller
|
32
|
+
Fog::Logger.warning("Error while loading provider #{provider_alias}: #{e.message}")
|
33
|
+
Fog::Logger.debug("backtrace: #{e.backtrace.join("\n")}")
|
34
|
+
raise Fog::Service::NotFound, "#{provider_alias} has no #{service_name.downcase} service"
|
19
35
|
end
|
20
36
|
|
21
37
|
def providers
|
@@ -24,16 +40,28 @@ module Fog
|
|
24
40
|
|
25
41
|
private
|
26
42
|
|
43
|
+
# This method should be removed once all providers are extracted.
|
44
|
+
# Bundler will correctly require all dependencies automatically and thus
|
45
|
+
# fog-core wont need to know any specifics providers. Each provider will
|
46
|
+
# have to load its dependencies.
|
27
47
|
def require_service_provider_library(service, provider)
|
28
48
|
require "fog/#{provider}/#{service}"
|
29
49
|
rescue LoadError # Try to require the service provider in an alternate location
|
50
|
+
Fog::Logger.deprecation("Unable to require fog/#{provider}/#{service}")
|
51
|
+
Fog::Logger.deprecation(
|
52
|
+
format(E_SERVICE_PROVIDER_PATH, service: service, provider: provider)
|
53
|
+
)
|
30
54
|
require "fog/#{service}/#{provider}"
|
31
55
|
end
|
32
56
|
|
33
57
|
def service_provider_constant(service_name, provider_name)
|
34
|
-
Fog.const_get(service_name).const_get(*const_get_args(provider_name))
|
35
|
-
rescue NameError # Try to find the constant from in an alternate location
|
36
58
|
Fog.const_get(provider_name).const_get(*const_get_args(service_name))
|
59
|
+
rescue NameError # Try to find the constant from in an alternate location
|
60
|
+
Fog::Logger.deprecation("Unable to load Fog::#{provider_name}::#{service_name}")
|
61
|
+
Fog::Logger.deprecation(
|
62
|
+
format(E_SERVICE_PROVIDER_CONSTANT, service: service_name, provider: provider_name)
|
63
|
+
)
|
64
|
+
Fog.const_get(service_name).const_get(*const_get_args(provider_name))
|
37
65
|
end
|
38
66
|
|
39
67
|
def const_get_args(*args)
|
@@ -43,5 +71,29 @@ module Fog
|
|
43
71
|
def service_name
|
44
72
|
name.split("Fog::").last
|
45
73
|
end
|
74
|
+
|
75
|
+
def check_provider_alias(provider)
|
76
|
+
case provider
|
77
|
+
when :baremetalcloud
|
78
|
+
Fog::Logger.deprecation(':baremetalcloud is deprecated. Use :bare_metal_cloud instead!')
|
79
|
+
:bare_metal_cloud
|
80
|
+
when :gogrid
|
81
|
+
Fog::Logger.deprecation(':gogrid is deprecated. Use :go_grid instead!')
|
82
|
+
:go_grid
|
83
|
+
when :internetarchive
|
84
|
+
Fog::Logger.deprecation(':internetarchive is deprecated. Use :internet_archive instead!')
|
85
|
+
:internet_archive
|
86
|
+
when :new_servers
|
87
|
+
Fog::Logger.deprecation(':new_servers is deprecated. Use :bare_metal_cloud instead!')
|
88
|
+
:bare_metal_cloud
|
89
|
+
when :stormondemand
|
90
|
+
Fog::Logger.deprecation(':stormondemand is deprecated. Use :storm_on_demand instead!')
|
91
|
+
:storm_on_demand
|
92
|
+
when :vclouddirector
|
93
|
+
Fog::Logger.deprecation(':vclouddirector is deprecated. Use :vcloud_director instead!')
|
94
|
+
:vcloud_director
|
95
|
+
else provider
|
96
|
+
end
|
97
|
+
end
|
46
98
|
end
|
47
99
|
end
|
data/lib/fog/core/ssh.rb
CHANGED
@@ -34,32 +34,10 @@ module Fog
|
|
34
34
|
|
35
35
|
class Real
|
36
36
|
def initialize(address, username, options)
|
37
|
-
|
38
|
-
require "net/ssh"
|
39
|
-
rescue LoadError
|
40
|
-
Fog::Logger.warning("'net/ssh' missing, please install and try again.")
|
41
|
-
exit(1)
|
42
|
-
end
|
43
|
-
|
44
|
-
key_manager = Net::SSH::Authentication::KeyManager.new(nil, options)
|
45
|
-
|
46
|
-
unless options[:key_data] || options[:keys] || options[:password] || key_manager.agent
|
47
|
-
raise ArgumentError, ":key_data, :keys, :password or a loaded ssh-agent is required to initialize SSH"
|
48
|
-
end
|
49
|
-
|
50
|
-
options[:timeout] ||= 30
|
51
|
-
if options[:key_data] || options[:keys]
|
52
|
-
options[:keys_only] = true
|
53
|
-
# Explicitly set these so net-ssh doesn"t add the default keys
|
54
|
-
# as seen at https://github.com/net-ssh/net-ssh/blob/master/lib/net/ssh/authentication/session.rb#L131-146
|
55
|
-
options[:keys] = [] unless options[:keys]
|
56
|
-
options[:key_data] = [] unless options[:key_data]
|
57
|
-
end
|
58
|
-
|
37
|
+
assert_net_ssh_loaded
|
59
38
|
@address = address
|
60
39
|
@username = username
|
61
|
-
@options
|
62
|
-
@options.delete(:paranoid) if Net::SSH::VALID_OPTIONS.include? :verify_host_key
|
40
|
+
@options = build_options(options)
|
63
41
|
end
|
64
42
|
|
65
43
|
def run(commands, &blk)
|
@@ -107,6 +85,51 @@ module Fog
|
|
107
85
|
end
|
108
86
|
results
|
109
87
|
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def assert_net_ssh_loaded
|
92
|
+
begin
|
93
|
+
require "net/ssh"
|
94
|
+
rescue LoadError
|
95
|
+
Fog::Logger.warning("'net/ssh' missing, please install and try again.")
|
96
|
+
exit(1)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Modifies the given `options` hash AND returns a new hash.
|
101
|
+
# TODO: Probably shouldn't modify the given hash.
|
102
|
+
def build_options(options)
|
103
|
+
validate_options(options)
|
104
|
+
merge_default_options_into(options)
|
105
|
+
end
|
106
|
+
|
107
|
+
def merge_default_options_into(options)
|
108
|
+
options[:timeout] ||= 30
|
109
|
+
if options[:key_data] || options[:keys]
|
110
|
+
options[:keys_only] = true
|
111
|
+
# Explicitly set these so net-ssh doesn"t add the default keys
|
112
|
+
# as seen at https://github.com/net-ssh/net-ssh/blob/master/lib/net/ssh/authentication/session.rb#L131-146
|
113
|
+
options[:keys] = [] unless options[:keys]
|
114
|
+
options[:key_data] = [] unless options[:key_data]
|
115
|
+
end
|
116
|
+
|
117
|
+
# net-ssh has deprecated :paranoid in favor of :verify_host_key
|
118
|
+
# https://github.com/net-ssh/net-ssh/pull/524
|
119
|
+
opts = { :paranoid => false, :verify_host_key => :never }.merge(options)
|
120
|
+
if Net::SSH::VALID_OPTIONS.include? :verify_host_key
|
121
|
+
opts.delete(:paranoid)
|
122
|
+
end
|
123
|
+
opts[:verify_host_key] = false unless Net::SSH::Verifiers.const_defined?(:Never)
|
124
|
+
opts
|
125
|
+
end
|
126
|
+
|
127
|
+
def validate_options(options)
|
128
|
+
key_manager = Net::SSH::Authentication::KeyManager.new(nil, options)
|
129
|
+
unless options[:key_data] || options[:keys] || options[:password] || key_manager.agent
|
130
|
+
raise ArgumentError, ":key_data, :keys, :password or a loaded ssh-agent is required to initialize SSH"
|
131
|
+
end
|
132
|
+
end
|
110
133
|
end
|
111
134
|
|
112
135
|
class Result
|
data/lib/fog/core/version.rb
CHANGED
data/lib/fog/dns.rb
CHANGED
@@ -2,17 +2,6 @@ module Fog
|
|
2
2
|
module DNS
|
3
3
|
extend Fog::ServicesMixin
|
4
4
|
|
5
|
-
def self.new(orig_attributes)
|
6
|
-
attributes = orig_attributes.dup # prevent delete from having side effects
|
7
|
-
case attributes.delete(:provider).to_s.downcase.to_sym
|
8
|
-
when :stormondemand
|
9
|
-
require "fog/dns/storm_on_demand"
|
10
|
-
Fog::DNS::StormOnDemand.new(attributes)
|
11
|
-
else
|
12
|
-
super(orig_attributes)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
5
|
def self.zones
|
17
6
|
zones = []
|
18
7
|
providers.each do |provider|
|
data/lib/fog/monitoring.rb
CHANGED
@@ -1,16 +1,5 @@
|
|
1
1
|
module Fog
|
2
2
|
module Monitoring
|
3
3
|
extend Fog::ServicesMixin
|
4
|
-
|
5
|
-
def self.new(orig_attributes)
|
6
|
-
attributes = orig_attributes.dup
|
7
|
-
provider = attributes.delete(:provider).to_s.downcase.to_sym
|
8
|
-
if provider == :stormondemand
|
9
|
-
require "fog/monitoring/storm_on_demand"
|
10
|
-
Fog::Monitoring::StormOnDemand.new(attributes)
|
11
|
-
else
|
12
|
-
super(orig_attributes)
|
13
|
-
end
|
14
|
-
end
|
15
4
|
end
|
16
5
|
end
|
data/lib/fog/network.rb
CHANGED
@@ -1,17 +1,5 @@
|
|
1
1
|
module Fog
|
2
2
|
module Network
|
3
3
|
extend Fog::ServicesMixin
|
4
|
-
|
5
|
-
def self.new(orig_attributes)
|
6
|
-
attributes = orig_attributes.dup # Prevent delete from having side effects
|
7
|
-
provider = attributes.delete(:provider).to_s.downcase.to_sym
|
8
|
-
|
9
|
-
if provider == :stormondemand
|
10
|
-
require "fog/network/storm_on_demand"
|
11
|
-
return Fog::Network::StormOnDemand.new(attributes)
|
12
|
-
else
|
13
|
-
super(orig_attributes)
|
14
|
-
end
|
15
|
-
end
|
16
4
|
end
|
17
5
|
end
|
data/lib/fog/storage.rb
CHANGED
@@ -9,20 +9,6 @@ module Fog
|
|
9
9
|
module Storage
|
10
10
|
extend Fog::ServicesMixin
|
11
11
|
|
12
|
-
def self.new(orig_attributes)
|
13
|
-
attributes = orig_attributes.dup # prevent delete from having side effects
|
14
|
-
case attributes.delete(:provider).to_s.downcase.to_sym
|
15
|
-
when :internetarchive
|
16
|
-
require "fog/internet_archive/storage"
|
17
|
-
Fog::Storage::InternetArchive.new(attributes)
|
18
|
-
when :stormondemand
|
19
|
-
require "fog/storage/storm_on_demand"
|
20
|
-
Fog::Storage::StormOnDemand.new(attributes)
|
21
|
-
else
|
22
|
-
super(orig_attributes)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
12
|
def self.directories
|
27
13
|
directories = []
|
28
14
|
providers.each do |provider|
|
data/lib/fog/support.rb
CHANGED
@@ -1,17 +1,5 @@
|
|
1
1
|
module Fog
|
2
2
|
module Support
|
3
3
|
extend Fog::ServicesMixin
|
4
|
-
|
5
|
-
def self.new(orig_attributes)
|
6
|
-
attributes = orig_attributes.dup
|
7
|
-
provider = attributes.delete(:provider).to_s.downcase.to_sym
|
8
|
-
|
9
|
-
if provider == :stormondemand
|
10
|
-
require "fog/support/storm_on_demand"
|
11
|
-
Fog::Support::StormOnDemand.new(attributes)
|
12
|
-
else
|
13
|
-
super(orig_attributes)
|
14
|
-
end
|
15
|
-
end
|
16
4
|
end
|
17
5
|
end
|
data/lib/fog/vpn.rb
CHANGED
@@ -1,17 +1,5 @@
|
|
1
1
|
module Fog
|
2
2
|
module VPN
|
3
3
|
extend Fog::ServicesMixin
|
4
|
-
|
5
|
-
def self.new(orig_attributes)
|
6
|
-
attributes = orig_attributes.dup
|
7
|
-
provider = attributes.delete(:provider).to_s.downcase.to_sym
|
8
|
-
|
9
|
-
if provider == :stormondemand
|
10
|
-
require "fog/vpn/storm_on_demand"
|
11
|
-
Fog::VPN::StormOnDemand.new(attributes)
|
12
|
-
else
|
13
|
-
super(orig_attributes)
|
14
|
-
end
|
15
|
-
end
|
16
4
|
end
|
17
5
|
end
|
data/spec/compute_spec.rb
CHANGED
@@ -10,74 +10,74 @@ describe "Fog::Compute" do
|
|
10
10
|
describe "#new" do
|
11
11
|
module Fog
|
12
12
|
module TheRightWay
|
13
|
-
|
14
|
-
|
13
|
+
class Compute
|
14
|
+
def initialize(_args); end
|
15
|
+
end
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
19
|
module Fog
|
19
|
-
module
|
20
|
-
|
21
|
-
|
22
|
-
end
|
20
|
+
module TheRightWay
|
21
|
+
extend Provider
|
22
|
+
service(:compute, "Compute")
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
it "instantiates an instance of Fog::Compute::<Provider> from the :provider keyword arg" do
|
27
27
|
compute = Fog::Compute.new(:provider => :therightway)
|
28
|
-
assert_instance_of(Fog::Compute
|
28
|
+
assert_instance_of(Fog::TheRightWay::Compute, compute)
|
29
29
|
end
|
30
30
|
|
31
31
|
module Fog
|
32
|
-
module
|
33
|
-
|
34
|
-
|
32
|
+
module Compute
|
33
|
+
class TheWrongWay
|
34
|
+
def initialize(_args); end
|
35
|
+
end
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
39
|
module Fog
|
39
40
|
module TheWrongWay
|
40
|
-
|
41
|
-
|
42
|
-
end
|
41
|
+
extend Provider
|
42
|
+
service(:compute, "Compute")
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
it "instantiates an instance of Fog::<Provider>::Compute from the :provider keyword arg" do
|
47
47
|
compute = Fog::Compute.new(:provider => :thewrongway)
|
48
|
-
assert_instance_of(Fog::TheWrongWay
|
48
|
+
assert_instance_of(Fog::Compute::TheWrongWay, compute)
|
49
49
|
end
|
50
50
|
|
51
51
|
module Fog
|
52
52
|
module BothWays
|
53
|
-
|
54
|
-
|
53
|
+
class Compute
|
54
|
+
attr_reader :args
|
55
|
+
def initialize(args)
|
56
|
+
@args = args
|
57
|
+
end
|
58
|
+
end
|
55
59
|
end
|
56
60
|
end
|
57
61
|
|
58
62
|
module Fog
|
59
|
-
module
|
60
|
-
class
|
63
|
+
module Compute
|
64
|
+
class BothWays
|
61
65
|
def initialize(_args); end
|
62
66
|
end
|
63
67
|
end
|
64
68
|
end
|
65
69
|
|
66
70
|
module Fog
|
67
|
-
module
|
68
|
-
|
69
|
-
|
70
|
-
def initialize(args)
|
71
|
-
@args = args
|
72
|
-
end
|
73
|
-
end
|
71
|
+
module BothWays
|
72
|
+
extend Provider
|
73
|
+
service(:compute, "Compute")
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
describe "when both Fog::Compute::<Provider> and Fog::<Provider>::Compute exist" do
|
78
|
-
it "prefers Fog
|
78
|
+
it "prefers Fog::<Provider>::Compute" do
|
79
79
|
compute = Fog::Compute.new(:provider => :bothways)
|
80
|
-
assert_instance_of(Fog::Compute
|
80
|
+
assert_instance_of(Fog::BothWays::Compute, compute)
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|