fog-core 2.3.0 → 2.5.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 +4 -4
- data/.github/FUNDING.yml +2 -0
- data/.github/dependabot.yml +2 -2
- data/.github/workflows/ci.yml +32 -0
- data/.rubocop.yml +16 -12
- data/.rubocop_todo.yml +724 -0
- data/Gemfile +1 -1
- data/README.md +2 -1
- data/Rakefile +2 -14
- data/SECURITY.md +6 -0
- data/changelog.md +26 -0
- data/fog-core.gemspec +11 -8
- data/lib/fog/compute/models/server.rb +7 -3
- data/lib/fog/compute.rb +3 -3
- data/lib/fog/core/association.rb +1 -0
- data/lib/fog/core/attributes/default.rb +7 -0
- data/lib/fog/core/attributes.rb +28 -3
- data/lib/fog/core/cache.rb +58 -55
- data/lib/fog/core/collection.rb +9 -3
- data/lib/fog/core/connection.rb +1 -1
- data/lib/fog/core/current_machine.rb +1 -1
- data/lib/fog/core/errors.rb +1 -1
- data/lib/fog/core/logger.rb +2 -2
- data/lib/fog/core/mock.rb +7 -2
- data/lib/fog/core/model.rb +34 -5
- data/lib/fog/core/provider.rb +7 -7
- data/lib/fog/core/scp.rb +15 -11
- data/lib/fog/core/service.rb +5 -5
- data/lib/fog/core/services_mixin.rb +9 -9
- data/lib/fog/core/ssh.rb +3 -2
- data/lib/fog/core/stringify_keys.rb +0 -2
- data/lib/fog/core/time.rb +2 -2
- data/lib/fog/core/uuid.rb +2 -8
- data/lib/fog/core/version.rb +1 -1
- data/lib/fog/core/wait_for.rb +2 -1
- data/lib/fog/core/wait_for_defaults.rb +2 -0
- data/lib/fog/core.rb +57 -59
- data/lib/fog/formatador.rb +9 -8
- data/lib/fog/schema/data_validator.rb +1 -0
- data/lib/fog/storage.rb +15 -16
- data/lib/fog/test_helpers/collection_helper.rb +2 -0
- data/lib/fog/test_helpers/formats_helper.rb +2 -2
- data/lib/fog/test_helpers/helper.rb +3 -3
- data/lib/fog/test_helpers/minitest/assertions.rb +1 -1
- data/lib/fog/test_helpers/minitest/expectations.rb +1 -1
- data/lib/fog/test_helpers/mock_helper.rb +84 -84
- data/lib/fog/test_helpers/types_helper.rb +1 -0
- data/lib/tasks/test_task.rb +4 -5
- metadata +46 -81
- data/.github/workflows/ruby.yml +0 -18
- data/.github/workflows/stale.yml +0 -9
- data/spec/compute/models/server_spec.rb +0 -229
- data/spec/compute_spec.rb +0 -95
- data/spec/connection_spec.rb +0 -105
- data/spec/core/cache_spec.rb +0 -191
- data/spec/core/model_spec.rb +0 -36
- data/spec/core/stringify_keys_spec.rb +0 -38
- data/spec/core/whitelist_keys_spec.rb +0 -36
- data/spec/credentials_spec.rb +0 -88
- data/spec/current_machine_spec.rb +0 -36
- data/spec/fake_app/fake_service.rb +0 -18
- data/spec/fake_app/models/collection.rb +0 -5
- data/spec/fake_app/models/model.rb +0 -2
- data/spec/fake_app/requests/request.rb +0 -11
- data/spec/fog_attribute_spec.rb +0 -549
- data/spec/formatador_spec.rb +0 -154
- data/spec/identity_spec.rb +0 -95
- data/spec/mocking_spec.rb +0 -84
- data/spec/service_spec.rb +0 -201
- data/spec/spec_helper.rb +0 -19
- data/spec/storage_spec.rb +0 -112
- data/spec/test_helpers/formats_helper_spec.rb +0 -121
- data/spec/test_helpers/schema_validator_spec.rb +0 -101
- data/spec/timeout_spec.rb +0 -20
- data/spec/utils_spec.rb +0 -29
- data/spec/uuid_spec.rb +0 -11
- data/spec/wait_for_spec.rb +0 -30
data/lib/fog/core/model.rb
CHANGED
@@ -21,6 +21,33 @@ module Fog
|
|
21
21
|
merge_attributes(attribs)
|
22
22
|
end
|
23
23
|
|
24
|
+
# Creates new or updates existing model
|
25
|
+
# @return [self]
|
26
|
+
def save
|
27
|
+
persisted? ? update : create
|
28
|
+
end
|
29
|
+
|
30
|
+
# Creates new entity from model
|
31
|
+
# @raise [Fog::Errors::NotImplemented] you must implement #create method in child class and return self
|
32
|
+
# @return [self]
|
33
|
+
def create
|
34
|
+
raise Fog::Errors::NotImplemented, "Implement method #create for #{self.class}. Method must return self"
|
35
|
+
end
|
36
|
+
|
37
|
+
# Updates new entity with model
|
38
|
+
# @raise [Fog::Errors::NotImplemented] you must implement #update method in child class and return self
|
39
|
+
# @return [self]
|
40
|
+
def update
|
41
|
+
raise Fog::Errors::NotImplemented, "Implement method #update for #{self.class}. Method must return self"
|
42
|
+
end
|
43
|
+
|
44
|
+
# Destroys entity by model identity
|
45
|
+
# @raise [Fog::Errors::NotImplemented] you must implement #destroy method in child class and return self
|
46
|
+
# @return [self]
|
47
|
+
def destroy
|
48
|
+
raise Fog::Errors::NotImplemented, "Implement method #destroy for #{self.class}. Method must return self"
|
49
|
+
end
|
50
|
+
|
24
51
|
def cache
|
25
52
|
Fog::Cache.new(self)
|
26
53
|
end
|
@@ -41,6 +68,8 @@ module Fog
|
|
41
68
|
end
|
42
69
|
end
|
43
70
|
|
71
|
+
# @return [self] if model successfully reloaded
|
72
|
+
# @return [nil] if something went wrong or model was not found
|
44
73
|
def reload
|
45
74
|
requires :identity
|
46
75
|
|
@@ -61,6 +90,7 @@ module Fog
|
|
61
90
|
|
62
91
|
def symbolize_keys(hash)
|
63
92
|
return nil if hash.nil?
|
93
|
+
|
64
94
|
hash.reduce({}) do |options, (key, value)|
|
65
95
|
options[(key.to_sym rescue key) || key] = value
|
66
96
|
options
|
@@ -69,6 +99,7 @@ module Fog
|
|
69
99
|
|
70
100
|
def wait_for(timeout = Fog.timeout, interval = Fog.interval, &block)
|
71
101
|
reload_has_succeeded = false
|
102
|
+
|
72
103
|
duration = Fog.wait_for(timeout, interval) do # Note that duration = false if it times out
|
73
104
|
if reload
|
74
105
|
reload_has_succeeded = true
|
@@ -77,11 +108,9 @@ module Fog
|
|
77
108
|
false
|
78
109
|
end
|
79
110
|
end
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
raise Fog::Errors::Error, "Reload failed, #{self.class} #{identity} not present."
|
84
|
-
end
|
111
|
+
raise Fog::Errors::Error, "Reload failed, #{self.class} #{identity} not present." unless reload_has_succeeded
|
112
|
+
|
113
|
+
duration # false if timeout; otherwise {:duration => elapsed time }
|
85
114
|
end
|
86
115
|
end
|
87
116
|
end
|
data/lib/fog/core/provider.rb
CHANGED
@@ -18,11 +18,11 @@ module Fog
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def underscore_name(string)
|
21
|
-
string.gsub(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -49,7 +49,7 @@ module Fog
|
|
49
49
|
[to_s, constant_string].join("::")
|
50
50
|
else
|
51
51
|
provider = to_s.split("::").last
|
52
|
-
Fog::Logger.deprecation("Unable to load #{[to_s, constant_string].join(
|
52
|
+
Fog::Logger.deprecation("Unable to load #{[to_s, constant_string].join('::')}")
|
53
53
|
Fog::Logger.deprecation(
|
54
54
|
format(
|
55
55
|
Fog::ServicesMixin::E_SERVICE_PROVIDER_CONSTANT,
|
@@ -57,7 +57,7 @@ module Fog
|
|
57
57
|
provider: provider
|
58
58
|
)
|
59
59
|
)
|
60
|
-
[
|
60
|
+
["Fog", constant_string, provider].join("::")
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
data/lib/fog/core/scp.rb
CHANGED
@@ -22,19 +22,23 @@ module Fog
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def upload(local_path, remote_path, upload_options = {})
|
25
|
-
self.class.data[@address] << {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
self.class.data[@address] << {
|
26
|
+
username: @username,
|
27
|
+
options: @options,
|
28
|
+
local_path: local_path,
|
29
|
+
remote_path: remote_path,
|
30
|
+
upload_options: upload_options
|
31
|
+
}
|
30
32
|
end
|
31
33
|
|
32
34
|
def download(remote_path, local_path, download_options = {})
|
33
|
-
self.class.data[@address] << {
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
self.class.data[@address] << {
|
36
|
+
username: @username,
|
37
|
+
options: @options,
|
38
|
+
remote_path: remote_path,
|
39
|
+
local_path: local_path,
|
40
|
+
download_options: download_options
|
41
|
+
}
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
@@ -64,7 +68,7 @@ module Fog
|
|
64
68
|
|
65
69
|
@address = address
|
66
70
|
@username = username
|
67
|
-
@options = { :
|
71
|
+
@options = { paranoid: false, verify_host_key: :never }.merge(options)
|
68
72
|
@options.delete(:paranoid) if Net::SSH::VALID_OPTIONS.include? :verify_host_key
|
69
73
|
@options[:verify_host_key] = false unless Net::SSH::Verifiers.const_defined?(:Never)
|
70
74
|
end
|
data/lib/fog/core/service.rb
CHANGED
@@ -11,7 +11,7 @@ module Fog
|
|
11
11
|
|
12
12
|
module NoLeakInspector
|
13
13
|
def inspect
|
14
|
-
"#<#{self.class}:#{object_id} #{(instance_variables - service.secrets).map { |iv| [iv, instance_variable_get(iv).inspect].join(
|
14
|
+
"#<#{self.class}:#{object_id} #{(instance_variables - service.secrets).map { |iv| [iv, instance_variable_get(iv).inspect].join('=') }.join(' ')}>"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -119,7 +119,7 @@ module Fog
|
|
119
119
|
# @deprecated
|
120
120
|
def fetch_credentials(_options)
|
121
121
|
# attempt to load credentials from config file
|
122
|
-
Fog.credentials.
|
122
|
+
Fog.credentials.select { |key, _value| (recognized | requirements).include?(key) }
|
123
123
|
rescue ::Fog::Errors::LoadError
|
124
124
|
# if there are no configured credentials, do nothing
|
125
125
|
{}
|
@@ -212,7 +212,7 @@ module Fog
|
|
212
212
|
@secrets ||= []
|
213
213
|
else
|
214
214
|
args.reduce(secrets) do |secrets, secret|
|
215
|
-
secrets << "@#{secret}"
|
215
|
+
secrets << :"@#{secret}"
|
216
216
|
end
|
217
217
|
end
|
218
218
|
end
|
@@ -241,13 +241,13 @@ module Fog
|
|
241
241
|
missing = requirements - keys
|
242
242
|
|
243
243
|
unless missing.empty?
|
244
|
-
raise ArgumentError, "Missing required arguments: #{missing.join(
|
244
|
+
raise ArgumentError, "Missing required arguments: #{missing.join(', ')}"
|
245
245
|
end
|
246
246
|
|
247
247
|
unless recognizes.empty?
|
248
248
|
unrecognized = options.keys - requirements - recognized
|
249
249
|
unless unrecognized.empty?
|
250
|
-
Fog::Logger.warning("Unrecognized arguments: #{unrecognized.join(
|
250
|
+
Fog::Logger.warning("Unrecognized arguments: #{unrecognized.join(', ')}")
|
251
251
|
end
|
252
252
|
end
|
253
253
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Fog
|
2
2
|
module ServicesMixin
|
3
|
-
E_SERVICE_PROVIDER_CONSTANT = <<-EOS.gsub(/\s+/,
|
3
|
+
E_SERVICE_PROVIDER_CONSTANT = <<-EOS.gsub(/\s+/, " ").strip.freeze
|
4
4
|
Falling back to deprecated constant Fog::%<service>s::%<provider>s. The
|
5
5
|
preferred format of service provider constants has changed from
|
6
6
|
service::provider to provider::service. Please update this service
|
7
7
|
provider to use the preferred format.
|
8
8
|
EOS
|
9
|
-
E_SERVICE_PROVIDER_PATH = <<-EOS.gsub(/\s+/,
|
9
|
+
E_SERVICE_PROVIDER_PATH = <<-EOS.gsub(/\s+/, " ").strip.freeze
|
10
10
|
Falling back to deprecated path fog/%<service>s/%<provider>s. The
|
11
11
|
preferred file path format has changed from service/provider to
|
12
12
|
provider/service. Please update this service provider to use the preferred
|
@@ -14,7 +14,7 @@ module Fog
|
|
14
14
|
EOS
|
15
15
|
|
16
16
|
def [](provider)
|
17
|
-
new(:
|
17
|
+
new(provider: provider)
|
18
18
|
end
|
19
19
|
|
20
20
|
def new(attributes)
|
@@ -75,22 +75,22 @@ module Fog
|
|
75
75
|
def check_provider_alias(provider)
|
76
76
|
case provider
|
77
77
|
when :baremetalcloud
|
78
|
-
Fog::Logger.deprecation(
|
78
|
+
Fog::Logger.deprecation(":baremetalcloud is deprecated. Use :bare_metal_cloud instead!")
|
79
79
|
:bare_metal_cloud
|
80
80
|
when :gogrid
|
81
|
-
Fog::Logger.deprecation(
|
81
|
+
Fog::Logger.deprecation(":gogrid is deprecated. Use :go_grid instead!")
|
82
82
|
:go_grid
|
83
83
|
when :internetarchive
|
84
|
-
Fog::Logger.deprecation(
|
84
|
+
Fog::Logger.deprecation(":internetarchive is deprecated. Use :internet_archive instead!")
|
85
85
|
:internet_archive
|
86
86
|
when :new_servers
|
87
|
-
Fog::Logger.deprecation(
|
87
|
+
Fog::Logger.deprecation(":new_servers is deprecated. Use :bare_metal_cloud instead!")
|
88
88
|
:bare_metal_cloud
|
89
89
|
when :stormondemand
|
90
|
-
Fog::Logger.deprecation(
|
90
|
+
Fog::Logger.deprecation(":stormondemand is deprecated. Use :storm_on_demand instead!")
|
91
91
|
:storm_on_demand
|
92
92
|
when :vclouddirector
|
93
|
-
Fog::Logger.deprecation(
|
93
|
+
Fog::Logger.deprecation(":vclouddirector is deprecated. Use :vcloud_director instead!")
|
94
94
|
:vcloud_director
|
95
95
|
else provider
|
96
96
|
end
|
data/lib/fog/core/ssh.rb
CHANGED
@@ -28,7 +28,7 @@ module Fog
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def run(commands, &_blk)
|
31
|
-
self.class.data[@address] << { :
|
31
|
+
self.class.data[@address] << { commands: commands, username: @username, options: @options }
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -61,6 +61,7 @@ module Fog
|
|
61
61
|
|
62
62
|
channel.on_extended_data do |_ch, type, data|
|
63
63
|
next unless type == 1
|
64
|
+
|
64
65
|
result.stderr << data
|
65
66
|
yield ["", data] if blk
|
66
67
|
end
|
@@ -116,7 +117,7 @@ module Fog
|
|
116
117
|
|
117
118
|
# net-ssh has deprecated :paranoid in favor of :verify_host_key
|
118
119
|
# https://github.com/net-ssh/net-ssh/pull/524
|
119
|
-
opts = { :
|
120
|
+
opts = { paranoid: false, verify_host_key: :never }.merge(options)
|
120
121
|
if Net::SSH::VALID_OPTIONS.include? :verify_host_key
|
121
122
|
opts.delete(:paranoid)
|
122
123
|
end
|
data/lib/fog/core/time.rb
CHANGED
@@ -2,8 +2,8 @@ require "time"
|
|
2
2
|
|
3
3
|
module Fog
|
4
4
|
class Time < ::Time
|
5
|
-
DAYS = %w(Sun Mon Tue Wed Thu Fri Sat)
|
6
|
-
MONTHS = %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
|
5
|
+
DAYS = %w(Sun Mon Tue Wed Thu Fri Sat).freeze
|
6
|
+
MONTHS = %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec).freeze
|
7
7
|
|
8
8
|
def self.now
|
9
9
|
at(::Time.now - offset)
|
data/lib/fog/core/uuid.rb
CHANGED
@@ -4,16 +4,10 @@ module Fog
|
|
4
4
|
class UUID
|
5
5
|
class << self
|
6
6
|
def uuid
|
7
|
-
|
8
|
-
SecureRandom.uuid
|
9
|
-
else
|
10
|
-
ary = SecureRandom.random_bytes(16).unpack("NnnnnN")
|
11
|
-
ary[2] = (ary[2] & 0x0fff) | 0x4000
|
12
|
-
ary[3] = (ary[3] & 0x3fff) | 0x8000
|
13
|
-
"%08x-%04x-%04x-%04x-%04x%08x" % ary
|
14
|
-
end
|
7
|
+
SecureRandom.uuid
|
15
8
|
end
|
16
9
|
|
10
|
+
# :nodoc: This method is used by other plugins, so preserve it for the compatibility
|
17
11
|
def supported?
|
18
12
|
SecureRandom.respond_to?(:uuid)
|
19
13
|
end
|
data/lib/fog/core/version.rb
CHANGED
data/lib/fog/core/wait_for.rb
CHANGED
@@ -8,9 +8,10 @@ module Fog
|
|
8
8
|
if duration > timeout
|
9
9
|
raise Errors::TimeoutError, "The specified wait_for timeout (#{timeout} seconds) was exceeded"
|
10
10
|
end
|
11
|
+
|
11
12
|
sleep(interval.respond_to?(:call) ? interval.call(retries += 1).to_f : interval.to_f)
|
12
13
|
duration = Time.now - start
|
13
14
|
end
|
14
|
-
{ :
|
15
|
+
{ duration: duration }
|
15
16
|
end
|
16
17
|
end
|
@@ -22,6 +22,7 @@ module Fog
|
|
22
22
|
|
23
23
|
def self.timeout=(timeout)
|
24
24
|
raise ArgumentError, "timeout must be non-negative" unless timeout >= 0
|
25
|
+
|
25
26
|
@timeout = timeout
|
26
27
|
end
|
27
28
|
|
@@ -33,6 +34,7 @@ module Fog
|
|
33
34
|
|
34
35
|
def self.max_interval=(interval)
|
35
36
|
raise ArgumentError, "interval must be non-negative" unless interval >= 0
|
37
|
+
|
36
38
|
@max_interval = interval
|
37
39
|
end
|
38
40
|
end
|
data/lib/fog/core.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# external core dependencies
|
2
|
-
require "base64"
|
3
2
|
require "cgi"
|
4
3
|
require "uri"
|
5
4
|
require "excon"
|
@@ -11,67 +10,66 @@ require "timeout"
|
|
11
10
|
require "ipaddr"
|
12
11
|
|
13
12
|
# internal core dependencies
|
14
|
-
require File.expand_path(
|
13
|
+
require File.expand_path("core/version", __dir__)
|
15
14
|
|
16
15
|
# Mixins
|
17
|
-
require File.expand_path(
|
16
|
+
require File.expand_path("core/services_mixin", __dir__)
|
18
17
|
|
19
|
-
require File.expand_path(
|
20
|
-
require File.expand_path(
|
21
|
-
require File.expand_path(
|
22
|
-
require File.expand_path(
|
23
|
-
require File.expand_path(
|
24
|
-
require File.expand_path(
|
25
|
-
require File.expand_path(
|
26
|
-
require File.expand_path(
|
27
|
-
require File.expand_path(
|
28
|
-
require File.expand_path(
|
29
|
-
require File.expand_path(
|
30
|
-
require File.expand_path(
|
31
|
-
require File.expand_path(
|
32
|
-
require File.expand_path(
|
33
|
-
require File.expand_path(
|
34
|
-
require File.expand_path(
|
35
|
-
require File.expand_path(
|
36
|
-
require File.expand_path(
|
37
|
-
require File.expand_path(
|
38
|
-
require File.expand_path(
|
39
|
-
require File.expand_path(
|
40
|
-
require File.expand_path(
|
41
|
-
require File.expand_path(
|
42
|
-
require File.expand_path(
|
43
|
-
require File.expand_path(
|
44
|
-
require File.expand_path(
|
45
|
-
require File.expand_path(
|
46
|
-
require File.expand_path(
|
47
|
-
require File.expand_path(
|
48
|
-
require File.expand_path(
|
49
|
-
require File.expand_path(
|
50
|
-
require File.expand_path(
|
51
|
-
require File.expand_path(
|
52
|
-
require File.expand_path(
|
53
|
-
require File.expand_path(
|
54
|
-
require File.expand_path(
|
55
|
-
|
56
|
-
require File.expand_path('../account', __FILE__)
|
57
|
-
require File.expand_path('../baremetal', __FILE__)
|
58
|
-
require File.expand_path('../billing', __FILE__)
|
59
|
-
require File.expand_path('../cdn', __FILE__)
|
60
|
-
require File.expand_path('../compute', __FILE__)
|
61
|
-
require File.expand_path('../dns', __FILE__)
|
62
|
-
require File.expand_path('../identity', __FILE__)
|
63
|
-
require File.expand_path('../image', __FILE__)
|
64
|
-
require File.expand_path('../introspection', __FILE__)
|
65
|
-
require File.expand_path('../metering', __FILE__)
|
66
|
-
require File.expand_path('../monitoring', __FILE__)
|
67
|
-
require File.expand_path('../nfv', __FILE__)
|
68
|
-
require File.expand_path('../network', __FILE__)
|
69
|
-
require File.expand_path('../orchestration', __FILE__)
|
70
|
-
require File.expand_path('../storage', __FILE__)
|
71
|
-
require File.expand_path('../support', __FILE__)
|
72
|
-
require File.expand_path('../volume', __FILE__)
|
73
|
-
require File.expand_path('../vpn', __FILE__)
|
18
|
+
require File.expand_path("core/attributes", __dir__)
|
19
|
+
require File.expand_path("core/attributes/default", __dir__)
|
20
|
+
require File.expand_path("core/attributes/array", __dir__)
|
21
|
+
require File.expand_path("core/attributes/boolean", __dir__)
|
22
|
+
require File.expand_path("core/attributes/float", __dir__)
|
23
|
+
require File.expand_path("core/attributes/integer", __dir__)
|
24
|
+
require File.expand_path("core/attributes/string", __dir__)
|
25
|
+
require File.expand_path("core/attributes/time", __dir__)
|
26
|
+
require File.expand_path("core/attributes/timestamp", __dir__)
|
27
|
+
require File.expand_path("core/associations/default", __dir__)
|
28
|
+
require File.expand_path("core/associations/many_identities", __dir__)
|
29
|
+
require File.expand_path("core/associations/many_models", __dir__)
|
30
|
+
require File.expand_path("core/associations/one_model", __dir__)
|
31
|
+
require File.expand_path("core/associations/one_identity", __dir__)
|
32
|
+
require File.expand_path("core/collection", __dir__)
|
33
|
+
require File.expand_path("core/association", __dir__)
|
34
|
+
require File.expand_path("core/connection", __dir__)
|
35
|
+
require File.expand_path("core/credentials", __dir__)
|
36
|
+
require File.expand_path("core/current_machine", __dir__)
|
37
|
+
require File.expand_path("core/deprecation", __dir__)
|
38
|
+
require File.expand_path("core/errors", __dir__)
|
39
|
+
require File.expand_path("core/hmac", __dir__)
|
40
|
+
require File.expand_path("core/logger", __dir__)
|
41
|
+
require File.expand_path("core/model", __dir__)
|
42
|
+
require File.expand_path("core/mock", __dir__)
|
43
|
+
require File.expand_path("core/provider", __dir__)
|
44
|
+
require File.expand_path("core/service", __dir__)
|
45
|
+
require File.expand_path("core/ssh", __dir__)
|
46
|
+
require File.expand_path("core/scp", __dir__)
|
47
|
+
require File.expand_path("core/time", __dir__)
|
48
|
+
require File.expand_path("core/utils", __dir__)
|
49
|
+
require File.expand_path("core/wait_for", __dir__)
|
50
|
+
require File.expand_path("core/wait_for_defaults", __dir__)
|
51
|
+
require File.expand_path("core/uuid", __dir__)
|
52
|
+
require File.expand_path("core/stringify_keys", __dir__)
|
53
|
+
require File.expand_path("core/whitelist_keys", __dir__)
|
74
54
|
|
55
|
+
require File.expand_path("account", __dir__)
|
56
|
+
require File.expand_path("baremetal", __dir__)
|
57
|
+
require File.expand_path("billing", __dir__)
|
58
|
+
require File.expand_path("cdn", __dir__)
|
59
|
+
require File.expand_path("compute", __dir__)
|
60
|
+
require File.expand_path("dns", __dir__)
|
61
|
+
require File.expand_path("identity", __dir__)
|
62
|
+
require File.expand_path("image", __dir__)
|
63
|
+
require File.expand_path("introspection", __dir__)
|
64
|
+
require File.expand_path("metering", __dir__)
|
65
|
+
require File.expand_path("monitoring", __dir__)
|
66
|
+
require File.expand_path("nfv", __dir__)
|
67
|
+
require File.expand_path("network", __dir__)
|
68
|
+
require File.expand_path("orchestration", __dir__)
|
69
|
+
require File.expand_path("storage", __dir__)
|
70
|
+
require File.expand_path("support", __dir__)
|
71
|
+
require File.expand_path("volume", __dir__)
|
72
|
+
require File.expand_path("vpn", __dir__)
|
75
73
|
|
76
74
|
# Utility
|
77
|
-
require File.expand_path(
|
75
|
+
require File.expand_path("formatador", __dir__)
|
data/lib/fog/formatador.rb
CHANGED
@@ -9,8 +9,8 @@ module Fog
|
|
9
9
|
Thread.current[:formatador] ||= ::Formatador.new
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.format(object, opts = { :
|
13
|
-
string = init_string(object)
|
12
|
+
def self.format(object, opts = { include_nested: true })
|
13
|
+
string = +init_string(object)
|
14
14
|
indent { string << object_string(object, opts) }
|
15
15
|
string << "#{indentation}>"
|
16
16
|
end
|
@@ -32,11 +32,9 @@ module Fog
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.redisplay_progressbar(current, total, options = {})
|
35
|
-
::Formatador.redisplay_progressbar(current, total, options
|
35
|
+
::Formatador.redisplay_progressbar(current, total, options)
|
36
36
|
end
|
37
37
|
|
38
|
-
private
|
39
|
-
|
40
38
|
def self.indent(&block)
|
41
39
|
formatador.indent(&block)
|
42
40
|
end
|
@@ -50,13 +48,14 @@ module Fog
|
|
50
48
|
end
|
51
49
|
|
52
50
|
def self.object_string(object, opts)
|
53
|
-
string =
|
54
|
-
string <<
|
51
|
+
string = +attribute_string(object).to_s
|
52
|
+
string << nested_objects_string(object).to_s if opts[:include_nested]
|
55
53
|
string
|
56
54
|
end
|
57
55
|
|
58
56
|
def self.attribute_string(object)
|
59
57
|
return "" unless object.class.respond_to?(:attributes)
|
58
|
+
|
60
59
|
if object.class.attributes.empty?
|
61
60
|
""
|
62
61
|
else
|
@@ -68,7 +67,8 @@ module Fog
|
|
68
67
|
nested = ""
|
69
68
|
return nested if object.respond_to?(:empty) and object.empty?
|
70
69
|
return nested unless object.is_a?(Enumerable)
|
71
|
-
|
70
|
+
|
71
|
+
nested = +"#{indentation}[\n"
|
72
72
|
indent { nested << indentation + inspect_object(object) }
|
73
73
|
nested << "#{indentation}\n#{indentation}]\n"
|
74
74
|
end
|
@@ -82,6 +82,7 @@ module Fog
|
|
82
82
|
|
83
83
|
def self.inspect_object(object)
|
84
84
|
return "" unless object.is_a?(Enumerable)
|
85
|
+
|
85
86
|
object.map { |o| indentation + o.inspect }.join(", \n#{indentation}")
|
86
87
|
end
|
87
88
|
end
|
data/lib/fog/storage.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
begin
|
2
2
|
# Use mime/types/columnar if available, for reduced memory usage
|
3
|
-
require
|
3
|
+
require "mime/types/columnar"
|
4
4
|
rescue LoadError
|
5
|
-
require
|
5
|
+
require "mime/types"
|
6
6
|
end
|
7
7
|
|
8
8
|
module Fog
|
@@ -24,18 +24,18 @@ module Fog
|
|
24
24
|
if body.respond_to?(:encoding)
|
25
25
|
original_encoding = body.encoding
|
26
26
|
body = body.dup if body.frozen?
|
27
|
-
body = body.force_encoding(
|
27
|
+
body = body.force_encoding("BINARY")
|
28
28
|
end
|
29
29
|
|
30
30
|
size = if body.respond_to?(:bytesize)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
body.bytesize
|
32
|
+
elsif body.respond_to?(:size)
|
33
|
+
body.size
|
34
|
+
elsif body.respond_to?(:stat)
|
35
|
+
body.stat.size
|
36
|
+
else
|
37
|
+
0
|
38
|
+
end
|
39
39
|
|
40
40
|
if body.respond_to?(:encoding)
|
41
41
|
body.force_encoding(original_encoding)
|
@@ -55,11 +55,10 @@ module Fog
|
|
55
55
|
|
56
56
|
def self.parse_data(data)
|
57
57
|
{
|
58
|
-
:
|
59
|
-
:
|
60
|
-
"Content-Length"
|
61
|
-
"Content-Type"
|
62
|
-
# "Content-MD5" => Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
|
58
|
+
body: data,
|
59
|
+
headers: {
|
60
|
+
"Content-Length" => get_body_size(data),
|
61
|
+
"Content-Type" => get_content_type(data)
|
63
62
|
}
|
64
63
|
}
|
65
64
|
end
|
@@ -35,6 +35,7 @@ def collection_tests(collection, params = {}, mocks_implemented = true)
|
|
35
35
|
|
36
36
|
methods.each do |enum_method|
|
37
37
|
next unless collection.respond_to?(enum_method)
|
38
|
+
|
38
39
|
tests("##{enum_method}").succeeds do
|
39
40
|
block_called = false
|
40
41
|
collection.send(enum_method) { block_called = true }
|
@@ -44,6 +45,7 @@ def collection_tests(collection, params = {}, mocks_implemented = true)
|
|
44
45
|
|
45
46
|
%w(max_by min_by).each do |enum_method|
|
46
47
|
next unless collection.respond_to?(enum_method)
|
48
|
+
|
47
49
|
tests("##{enum_method}").succeeds do
|
48
50
|
block_called = false
|
49
51
|
collection.send(enum_method) do
|
@@ -60,9 +60,9 @@ module Shindo
|
|
60
60
|
def formats(format, strict = true)
|
61
61
|
test("has proper format") do
|
62
62
|
if strict
|
63
|
-
options = { :
|
63
|
+
options = { allow_extra_keys: false, allow_optional_rules: true }
|
64
64
|
else
|
65
|
-
options = { :
|
65
|
+
options = { allow_extra_keys: true, allow_optional_rules: true }
|
66
66
|
end
|
67
67
|
validator = Fog::Schema::DataValidator.new
|
68
68
|
valid = validator.validate(yield, format, options)
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require "excon"
|
2
2
|
|
3
|
-
ENV["FOG_RC"] = ENV["FOG_RC"] || File.expand_path("
|
3
|
+
ENV["FOG_RC"] = ENV["FOG_RC"] || File.expand_path(".fog", __dir__)
|
4
4
|
ENV["FOG_CREDENTIAL"] = ENV["FOG_CREDENTIAL"] || "default"
|
5
5
|
|
6
|
-
Excon.defaults.merge!(:
|
6
|
+
Excon.defaults.merge!(debug_request: true, debug_response: true)
|
7
7
|
|
8
|
-
LOREM = <<HERE
|
8
|
+
LOREM = <<HERE.freeze
|
9
9
|
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
|
10
10
|
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
|
11
11
|
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|