Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ gemfiles/Gemfile-1.9.lock
.DS_Store
.idea/
vendor/bundle
test/.lorem.txt
test/lorem.txt
14 changes: 14 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
inherit_from: .rubocop_todo.yml

plugins:
- rubocop-minitest

# Opt-in new cops
AllCops:
NewCops: enable
#
# Minitest
#
# minitest 6 dropped the Object monkeypatch that made bare `foo.must_equal bar`
# resolve, so expectations have to be written as `_(foo).must_equal bar`.
# Enable just the cop that guards that; the rest of the Minitest department is
# not part of this baseline yet.
Minitest:
Enabled: false
Minitest/GlobalExpectations:
Enabled: true
#
# Overrides
#
Layout/HashAlignment:
Expand Down
89 changes: 69 additions & 20 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 11
# Offense count: 14
# Configuration parameters: EnforcedStyle, AllowedGems.
# SupportedStyles: Gemfile, gems.rb, gemspec
Gemspec/DevelopmentDependencies:
Expand Down Expand Up @@ -1010,23 +1010,6 @@ Lint/UnusedMethodArgument:
- 'lib/fog/openstack/storage/requests/put_object.rb'
- 'lib/fog/openstack/workflow/v2.rb'

# Offense count: 13
Lint/UriEscapeUnescape:
Exclude:
- 'lib/fog/openstack/compute/requests/delete_service.rb'
- 'lib/fog/openstack/compute/requests/disable_service.rb'
- 'lib/fog/openstack/compute/requests/disable_service_log_reason.rb'
- 'lib/fog/openstack/compute/requests/enable_service.rb'
- 'lib/fog/openstack/storage/requests/delete_multiple_objects.rb'
- 'lib/fog/openstack/workflow/v2/requests/delete_action.rb'
- 'lib/fog/openstack/workflow/v2/requests/delete_cron_trigger.rb'
- 'lib/fog/openstack/workflow/v2/requests/delete_environment.rb'
- 'lib/fog/openstack/workflow/v2/requests/delete_workbook.rb'
- 'lib/fog/openstack/workflow/v2/requests/get_action.rb'
- 'lib/fog/openstack/workflow/v2/requests/get_cron_trigger.rb'
- 'lib/fog/openstack/workflow/v2/requests/get_environment.rb'
- 'lib/fog/openstack/workflow/v2/requests/get_workbook.rb'

# Offense count: 19
# This cop supports safe autocorrection (--autocorrect).
Lint/UselessAssignment:
Expand Down Expand Up @@ -1070,7 +1053,7 @@ Lint/Void:
Exclude:
- 'spec/image_v2_spec.rb'

# Offense count: 133
# Offense count: 134
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
Metrics/AbcSize:
Exclude:
Expand Down Expand Up @@ -1191,6 +1174,7 @@ Metrics/AbcSize:
- 'spec/shared_context.rb'
- 'spec/volume_spec.rb'
- 'test/helpers/collection_helper.rb'
- 'test/requests/storage/object_tests.rb'

# Offense count: 33
# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns.
Expand Down Expand Up @@ -1604,6 +1588,18 @@ Style/ClassVars:
- 'test/requests/compute/address_tests.rb'
- 'test/requests/compute/server_tests.rb'

# Offense count: 6
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedReceivers.
Style/CollectionCompact:
Exclude:
- 'lib/fog/openstack/compute/models/server.rb'
- 'lib/fog/openstack/image/v1/requests/create_image.rb'
- 'lib/fog/openstack/image/v1/requests/update_image.rb'
- 'lib/fog/openstack/storage/models/file.rb'
- 'lib/fog/openstack/storage/requests/get_container.rb'
- 'lib/fog/openstack/storage/requests/get_containers.rb'

# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/CommentedKeyword:
Expand Down Expand Up @@ -1810,6 +1806,19 @@ Style/HashEachMethods:
- 'lib/fog/openstack/network/requests/update_router.rb'
- 'test/requests/orchestration/stack_files_util_tests.rb'

# Offense count: 8
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/HashSlice:
Exclude:
- 'lib/fog/openstack/compute/models/address.rb'
- 'lib/fog/openstack/compute/models/key_pair.rb'
- 'lib/fog/openstack/compute/requests/list_images.rb'
- 'lib/fog/openstack/compute/requests/list_images_detail.rb'
- 'lib/fog/openstack/compute/requests/list_servers.rb'
- 'lib/fog/openstack/container_infra/models/bay.rb'
- 'lib/fog/openstack/container_infra/models/cluster.rb'
- 'lib/fog/openstack/image/v2/requests/update_image_member.rb'

# Offense count: 38
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
Expand Down Expand Up @@ -1972,6 +1981,16 @@ Style/NumericLiterals:
- 'lib/fog/openstack/metering/requests/get_samples.rb'
- 'lib/fog/openstack/network.rb'

# Offense count: 8
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
Exclude:
- 'spec/**/*'
- 'lib/fog/openstack/identity/v3/models/domains.rb'
- 'lib/fog/openstack/identity/v3/models/projects.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AlwaysCorrectToMultiline.
Expand Down Expand Up @@ -2068,14 +2087,19 @@ Style/RandomWithOffset:
- 'lib/fog/openstack/volume/v2/requests/get_volume_details.rb'
- 'lib/fog/openstack/volume/v3/requests/get_volume_details.rb'

# Offense count: 4
# Offense count: 29
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantBegin:
Exclude:
- 'lib/fog/openstack/compute/models/image.rb'
- 'lib/fog/openstack/compute/models/server.rb'
- 'lib/fog/openstack/storage/models/directory.rb'
- 'spec/identity_v3_spec.rb'
- 'spec/image_v2_spec.rb'
- 'spec/monitoring_spec.rb'
- 'spec/network_spec.rb'
- 'spec/shared_file_system_spec.rb'
- 'spec/volume_spec.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
Expand Down Expand Up @@ -2175,6 +2199,31 @@ Style/RescueStandardError:
- 'spec/identity_v3_spec.rb'
- 'spec/image_v2_spec.rb'

# Offense count: 61
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
# AllowedMethods: present?, blank?, presence, try, try!
Style/SafeNavigation:
Exclude:
- 'lib/fog/openstack/compute/models/metadata.rb'
- 'lib/fog/openstack/compute/requests/create_server.rb'
- 'lib/fog/openstack/identity/v2/models/ec2_credentials.rb'
- 'lib/fog/openstack/image/v1/requests/create_image.rb'
- 'lib/fog/openstack/image/v1/requests/update_image.rb'
- 'lib/fog/openstack/network/requests/create_router.rb'
- 'lib/fog/openstack/orchestration/models/stack.rb'
- 'lib/fog/openstack/orchestration/requests/list_events.rb'
- 'lib/fog/openstack/orchestration/requests/list_resources.rb'
- 'spec/identity_v3_spec.rb'
- 'spec/image_v2_spec.rb'
- 'spec/image_v2_upload_spec.rb'
- 'spec/monitoring_spec.rb'
- 'spec/network_spec.rb'
- 'spec/volume_spec.rb'
- 'test/models/compute/security_group_tests.rb'
- 'test/models/compute/server_tests.rb'
- 'test/requests/image/image_tests.rb'

# Offense count: 11
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowModifier.
Expand Down
2 changes: 2 additions & 0 deletions fog-openstack.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "mime-types"
spec.add_development_dependency "mime-types-data"
spec.add_development_dependency 'minitest'
spec.add_development_dependency 'minitest-mock'
spec.add_development_dependency 'pry-byebug'
spec.add_development_dependency 'rake', '>= 12.3.3'
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rubocop-minitest'
spec.add_development_dependency 'shindo', '~> 0.3'
spec.add_development_dependency 'vcr'
spec.add_development_dependency 'webmock', '~> 3.16.2'
Expand Down
19 changes: 12 additions & 7 deletions lib/fog/openstack/volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,23 @@ class Volume < Fog::Service
:openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id,
:openstack_identity_api_version]

# Fog::OpenStack::Image.new() will return a Fog::OpenStack::Volume::V3 or a Fog::OpenStack::Volume::V2 or a
# Fog::OpenStack::Volume.new() will return a Fog::OpenStack::Volume::V3 or a Fog::OpenStack::Volume::V2 or a
# Fog::OpenStack::Volume::V1, choosing the V3 by default, as V2 is deprecated since OpenStackWallaby and V1 is
# deprecated since OpenStack Juno
def self.new(args = {})
@openstack_auth_uri = URI.parse(args[:openstack_auth_url]) if args[:openstack_auth_url]
if inspect == 'Fog::OpenStack::Volume'
Fog::OpenStack::Volume::V3.new(args) \
|| Fog::OpenStack::Volume::V2.new(args) \
|| Fog::OpenStack::Volume::V1.new(args)
else
super
return super unless inspect == 'Fog::OpenStack::Volume'

# Each version resolves a different catalog entry: "volumev3", "volumev2"
# and "volume" respectively. Try them newest first and move on when the
# catalog does not advertise one, re-raising when none of them match.
last_error = nil
[V3, V2, V1].each do |version|
return version.new(args)
rescue Fog::OpenStack::Auth::Catalog::ServiceTypeError => e
last_error = e
end
raise last_error
end
end
end
Expand Down
26 changes: 13 additions & 13 deletions spec/dns_v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,30 @@
begin
# create zone
example_zone = @service.zones.create(:name => zone_name, :email => "hostmaster@#{zone}")
example_zone.status.must_equal 'PENDING'
example_zone.action.must_equal 'CREATE'
_(example_zone.status).must_equal 'PENDING'
_(example_zone.action).must_equal 'CREATE'
example_id = example_zone.id

# add a description
example_zone.update(:description => zone_description)
example_zone.reload.description.must_equal zone_description
_(example_zone.reload.description).must_equal zone_description

# get by ID
example_zone_by_id = @service.zones.find_by_id example_id
example_zone_by_id.wont_equal nil
example_zone_by_id.description.must_equal zone_description
_(example_zone_by_id).wont_equal nil
_(example_zone_by_id.description).must_equal zone_description

# get by filtering list by name
zones = @service.zones.all(:name => zone_name)
zones.length.must_equal 1
zones.first.id.must_equal example_id
_(zones.length).must_equal 1
_(zones.first.id).must_equal example_id
ensure
# delete the zone(s)
@service.zones.all(:name => zone_name).each(&:destroy)

# check delete action
@service.zones.all(:name => zone_name).each do |z|
z.action.must_equal 'DELETE'
_(z.action).must_equal 'DELETE'
end
end
end
Expand Down Expand Up @@ -75,17 +75,17 @@

# change record
host_record.update(:records => records_updated)
host_record.reload.records.must_equal records_updated
_(host_record.reload.records).must_equal records_updated

# get by ID
host_record_by_id = @service.recordsets.find_by_id(example_id, host_id)
host_record_by_id.wont_equal nil
host_record_by_id.records.must_equal records_updated
_(host_record_by_id).wont_equal nil
_(host_record_by_id.records).must_equal records_updated

# get by filtering list by name
recordsets = @service.recordsets.all(:zone_id => example_id, :name => recordset_name)
recordsets.length.must_equal 1
recordsets.first.id.must_equal host_id
_(recordsets.length).must_equal 1
_(recordsets.first.id).must_equal host_id
ensure
# delete the recordset(s)
@service.recordsets.all(:zone_id => example_id, :name => recordset_name).each(&:destroy)
Expand Down
Loading