Skip to content

Commit

Permalink
Introduce RuboCop and reformat all CPI code
Browse files Browse the repository at this point in the history
[#155618738](https://www.pivotaltracker.com/story/show/155618738)

Co-authored-by: Sebastian Heid <sebastian.heid@sap.com>
  • Loading branch information
beyhan and s4heid committed Mar 21, 2018
1 parent aa02de6 commit 8b36506
Show file tree
Hide file tree
Showing 75 changed files with 1,799 additions and 1,946 deletions.
58 changes: 58 additions & 0 deletions src/bosh_openstack_cpi/.rubocop.yml
@@ -0,0 +1,58 @@
AllCops:
TargetRubyVersion: 2.4
Include:
- Rakefile
Exclude:
- tmp/**/*

Style/FrozenStringLiteralComment:
Enabled: false

Style/ClassAndModuleChildren:
Enabled: false

Style/Documentation:
Enabled: false

Metrics/LineLength:
Max: 130

Metrics/ModuleLength:
Enabled: false

Metrics/ClassLength:
Max: 200

Metrics/MethodLength:
Max: 30

Metrics/BlockLength:
Max: 25
ExcludedMethods: [describe, context, let, it]

Style/BlockDelimiters:
Enabled: false

Style/TrailingCommaInArrayLiteral:
Enabled: true
EnforcedStyleForMultiline: comma

Style/TrailingCommaInHashLiteral:
Enabled: true
EnforcedStyleForMultiline: comma

Style/TrailingCommaInArguments:
Enabled: true
EnforcedStyleForMultiline: comma

Layout/MultilineMethodCallIndentation:
EnforcedStyle: aligned

Style/BracesAroundHashParameters:
EnforcedStyle: context_dependent

Layout/IndentHash:
EnforcedStyle: consistent

Style/WordArray:
Enabled: true
6 changes: 3 additions & 3 deletions src/bosh_openstack_cpi/Gemfile
Expand Up @@ -2,17 +2,17 @@ source 'https://rubygems.org'

gem 'bosh_common'
gem 'bosh_cpi', '=2.3.0'
gem 'fog-openstack', '~>0.1.24'
gem 'excon', '~>0.49'
gem 'fog-openstack', '~>0.1.24'
gem 'httpclient', '=2.8.3'
gem 'membrane', '~>1.1.0'
gem 'netaddr', '~>1.5.0'

group :development, :test do
gem 'minitar', '~> 0.5.4'
gem 'rake', '~>10.3.2'
gem 'rspec', '~> 3.3.0'
gem 'rspec-its', '~> 1.0.1'
gem 'minitar', '~> 0.5.4'
gem 'timecop', '~>0.7.1'
gem 'rake', '~>10.3.2'
gem 'webmock', '~>2.3.2'
end
22 changes: 11 additions & 11 deletions src/bosh_openstack_cpi/bin/bosh_openstack_console
Expand Up @@ -7,18 +7,18 @@
# {"default" => {"type" => "dynamic", "cloud_properties" => {"security_groups" => ["name" => "default"]}}},
# [],
# {"foo" =>"bar"})
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)

require "bosh_openstack_cpi"
require "irb"
require "irb/completion"
require "ostruct"
require "optparse"
require 'bosh_openstack_cpi'
require 'irb'
require 'irb/completion'
require 'ostruct'
require 'optparse'

config_file = nil

opts_parser = OptionParser.new do |opts|
opts.on("-c", "--config FILE") { |file| config_file = file }
opts.on('-c', '--config FILE') { |file| config_file = file }
end

opts_parser.parse!
Expand Down Expand Up @@ -48,20 +48,20 @@ module ConsoleHelpers
end
end

cloud_config = OpenStruct.new(:logger => Logger.new(STDOUT))
cloud_config = OpenStruct.new(logger: Logger.new(STDOUT))

Bosh::Clouds::Config.configure(cloud_config)

include ConsoleHelpers

begin
require 'ruby-debug'
puts "=> Debugger enabled"
puts '=> Debugger enabled'
rescue LoadError
puts "=> ruby-debug not found, debugger disabled"
puts '=> ruby-debug not found, debugger disabled'
end

puts "=> Welcome to BOSH OpenStack CPI console"
puts '=> Welcome to BOSH OpenStack CPI console'
puts "You can use 'cpi' to access CPI methods"
puts "You can use 'openstack' to access Fog::Compute::OpenStack methods"
puts "You can use 'glance' to access Fog::Image::OpenStack methods"
Expand Down
6 changes: 3 additions & 3 deletions src/bosh_openstack_cpi/bin/openstack_cpi
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)

require 'yaml'
require 'ostruct'
Expand All @@ -9,7 +9,7 @@ require 'cloud/openstack'
cpi_config = YAML.load_file(ARGV.shift)
ssl_ca_file = ARGV.shift

cloud_config = OpenStruct.new(:logger => Logger.new(STDERR))
cloud_config = OpenStruct.new(logger: Logger.new(STDERR))

Bosh::Clouds::Config.configure(cloud_config)

Expand All @@ -19,4 +19,4 @@ Dir.mktmpdir do |dir|
cli = Bosh::Cpi::Cli.new(cpi_lambda, cpi_log, STDOUT)

cli.run(ARGF.read)
end
end
2 changes: 1 addition & 1 deletion src/bosh_openstack_cpi/lib/bosh_openstack_cpi.rb
@@ -1 +1 @@
require "cloud/openstack"
require 'cloud/openstack'
72 changes: 36 additions & 36 deletions src/bosh_openstack_cpi/lib/cloud/openstack.rb
Expand Up @@ -2,48 +2,48 @@ module Bosh
module OpenStackCloud; end
end

require "fog/openstack"
require "httpclient"
require "json"
require "pp"
require "set"
require "tmpdir"
require "securerandom"
require "json"
require 'fog/openstack'
require 'httpclient'
require 'json'
require 'pp'
require 'set'
require 'tmpdir'
require 'securerandom'
require 'json'
require 'membrane'
require 'netaddr'

require 'common/common'
require "common/exec"
require "common/thread_pool"
require "common/thread_formatter"
require 'common/exec'
require 'common/thread_pool'
require 'common/thread_formatter'

require "bosh/cpi/registry_client"
require "bosh/cpi/redactor"
require "cloud"
require "cloud/openstack/helpers"
require "cloud/openstack/cloud"
require "cloud/openstack/cpi_lambda"
require "cloud/openstack/openstack"
require "cloud/openstack/tag_manager"
require 'bosh/cpi/registry_client'
require 'bosh/cpi/redactor'
require 'cloud'
require 'cloud/openstack/helpers'
require 'cloud/openstack/cloud'
require 'cloud/openstack/cpi_lambda'
require 'cloud/openstack/openstack'
require 'cloud/openstack/tag_manager'

require "cloud/openstack/network_configurator"
require "cloud/openstack/loadbalancer_configurator"
require "cloud/openstack/resource_pool"
require "cloud/openstack/security_groups"
require "cloud/openstack/floating_ip"
require "cloud/openstack/network"
require "cloud/openstack/private_network"
require "cloud/openstack/dynamic_network"
require "cloud/openstack/manual_network"
require "cloud/openstack/vip_network"
require "cloud/openstack/volume_configurator"
require "cloud/openstack/excon_logging_instrumentor"
require "cloud/openstack/availability_zone_provider"
require "cloud/openstack/stemcell"
require "cloud/openstack/stemcell_creator"
require "cloud/openstack/instance_type_mapper"
require "cloud/openstack/server_groups"
require 'cloud/openstack/network_configurator'
require 'cloud/openstack/loadbalancer_configurator'
require 'cloud/openstack/resource_pool'
require 'cloud/openstack/security_groups'
require 'cloud/openstack/floating_ip'
require 'cloud/openstack/network'
require 'cloud/openstack/private_network'
require 'cloud/openstack/dynamic_network'
require 'cloud/openstack/manual_network'
require 'cloud/openstack/vip_network'
require 'cloud/openstack/volume_configurator'
require 'cloud/openstack/excon_logging_instrumentor'
require 'cloud/openstack/availability_zone_provider'
require 'cloud/openstack/stemcell'
require 'cloud/openstack/stemcell_creator'
require 'cloud/openstack/instance_type_mapper'
require 'cloud/openstack/server_groups'

module Bosh
module Clouds
Expand Down
Expand Up @@ -39,11 +39,10 @@ def ignore_empty_string(string)
# @return [String] availability zone to use or nil
# @note this is a private method that is public to make it easier to test
def ensure_same_availability_zone(disks, default)
zones = disks.map { |disk| disk.availability_zone }
zones = disks.map(&:availability_zone)
zones << default if default
zones.uniq!
cloud_error "can't use multiple availability zones: %s" %
zones.join(', ') unless zones.size == 1
cloud_error format("can't use multiple availability zones: %s", zones.join(', ')) unless zones.size == 1
end
end
end

0 comments on commit 8b36506

Please sign in to comment.