From e5e945262712275e61ab536af5d18a67fef89dfa Mon Sep 17 00:00:00 2001 From: Daisuke Fujita Date: Tue, 2 Aug 2016 11:35:57 +0900 Subject: [PATCH] Restrict max line length to 140 --- .rubocop.yml | 2 +- Rakefile | 1 - lib/terraforming.rb | 2 +- lib/terraforming/cli.rb | 1 - .../resource/auto_scaling_group.rb | 2 +- .../resource/db_security_group.rb | 2 +- lib/terraforming/resource/ec2.rb | 38 +++++------ lib/terraforming/resource/eip.rb | 2 +- .../resource/elasti_cache_cluster.rb | 8 +-- lib/terraforming/resource/elb.rb | 11 ++- lib/terraforming/resource/iam_group.rb | 2 +- .../resource/iam_group_membership.rb | 2 +- .../resource/iam_policy_attachment.rb | 2 +- lib/terraforming/resource/iam_user.rb | 2 +- .../resource/launch_configuration.rb | 3 +- lib/terraforming/resource/nat_gateway.rb | 4 +- .../resource/network_interface.rb | 3 +- .../resource/opsworks_custom_layer.rb | 4 +- lib/terraforming/resource/opsworks_stack.rb | 1 - lib/terraforming/resource/route53_record.rb | 4 +- lib/terraforming/resource/route53_zone.rb | 6 +- lib/terraforming/resource/route_table.rb | 4 +- lib/terraforming/resource/security_group.rb | 9 ++- lib/terraforming/util.rb | 1 - spec/lib/terraforming/cli_spec.rb | 3 +- spec/lib/terraforming/resource/elb_spec.rb | 67 ++++++++++--------- .../resource/iam_group_membership_spec.rb | 4 +- .../resource/iam_group_policy_spec.rb | 2 +- .../terraforming/resource/iam_group_spec.rb | 4 +- .../resource/iam_instance_profile_spec.rb | 4 +- .../resource/iam_policy_attachment_spec.rb | 2 +- .../terraforming/resource/iam_policy_spec.rb | 2 +- .../terraforming/resource/iam_role_spec.rb | 4 +- .../resource/iam_user_policy_spec.rb | 2 +- .../terraforming/resource/iam_user_spec.rb | 4 +- .../terraforming/resource/nat_gateway_spec.rb | 4 +- .../resource/network_interface_spec.rb | 2 +- .../resource/route53_record_spec.rb | 6 +- .../resource/route53_zone_spec.rb | 34 +++++----- .../resource/route_table_association_spec.rb | 2 +- .../terraforming/resource/route_table_spec.rb | 6 +- spec/lib/terraforming/resource/s3_spec.rb | 2 +- spec/lib/terraforming/resource/vpc_spec.rb | 2 +- 43 files changed, 131 insertions(+), 141 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 9451e2fb..d618bee6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,7 +8,7 @@ Metrics/CyclomaticComplexity: Enabled: false Metrics/LineLength: - Max: 130 + Max: 140 Exclude: - "spec/**/*" diff --git a/Rakefile b/Rakefile index 9cdfeae9..b7e9ed54 100644 --- a/Rakefile +++ b/Rakefile @@ -4,4 +4,3 @@ require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) task :default => :spec - diff --git a/lib/terraforming.rb b/lib/terraforming.rb index 5b411ed5..c1648da1 100644 --- a/lib/terraforming.rb +++ b/lib/terraforming.rb @@ -3,7 +3,7 @@ begin require "ox" rescue NameError => e - spec = Gem::Specification.stubs.find {|s| s.name == 'ox' } + spec = Gem::Specification.stubs.find { |s| s.name == 'ox' } raise e unless spec require File.join(spec.gem_dir, "lib/ox") end diff --git a/lib/terraforming/cli.rb b/lib/terraforming/cli.rb index d924408b..02f87867 100644 --- a/lib/terraforming/cli.rb +++ b/lib/terraforming/cli.rb @@ -199,7 +199,6 @@ def vgw execute(Terraforming::Resource::VPNGateway, options) end - private def execute(klass, options) diff --git a/lib/terraforming/resource/auto_scaling_group.rb b/lib/terraforming/resource/auto_scaling_group.rb index 08aecd22..dd83ee14 100644 --- a/lib/terraforming/resource/auto_scaling_group.rb +++ b/lib/terraforming/resource/auto_scaling_group.rb @@ -83,7 +83,7 @@ def vpc_zone_identifier_of(group) end def vpc_zone_specified?(group) - group.vpc_zone_identifier && vpc_zone_identifier_of(group).length > 0 + group.vpc_zone_identifier && !vpc_zone_identifier_of(group).empty? end end end diff --git a/lib/terraforming/resource/db_security_group.rb b/lib/terraforming/resource/db_security_group.rb index eac6d534..09651ee4 100644 --- a/lib/terraforming/resource/db_security_group.rb +++ b/lib/terraforming/resource/db_security_group.rb @@ -46,7 +46,7 @@ def ingresses_of(security_group) end def db_security_groups - @client.describe_db_security_groups.map(&:db_security_groups).flatten.select { |sg| ingresses_of(sg).length > 0 } + @client.describe_db_security_groups.map(&:db_security_groups).flatten.select { |sg| !ingresses_of(sg).empty? } end def module_name_of(security_group) diff --git a/lib/terraforming/resource/ec2.rb b/lib/terraforming/resource/ec2.rb index cb2608c9..090cce3e 100644 --- a/lib/terraforming/resource/ec2.rb +++ b/lib/terraforming/resource/ec2.rb @@ -25,24 +25,24 @@ def tfstate block_devices = block_devices_of(instance) attributes = { - "ami"=> instance.image_id, - "associate_public_ip_address"=> "true", - "availability_zone"=> instance.placement.availability_zone, - "ebs_block_device.#"=> ebs_block_devices_in(block_devices, instance).length.to_s, - "ebs_optimized"=> instance.ebs_optimized.to_s, + "ami" => instance.image_id, + "associate_public_ip_address" => "true", + "availability_zone" => instance.placement.availability_zone, + "ebs_block_device.#" => ebs_block_devices_in(block_devices, instance).length.to_s, + "ebs_optimized" => instance.ebs_optimized.to_s, "ephemeral_block_device.#" => "0", # Terraform 0.6.1 cannot fetch this field from AWS - "id"=> instance.instance_id, - "instance_type"=> instance.instance_type, + "id" => instance.instance_id, + "instance_type" => instance.instance_type, "monitoring" => monitoring_state(instance).to_s, - "private_dns"=> instance.private_dns_name, - "private_ip"=> instance.private_ip_address, - "public_dns"=> instance.public_dns_name, - "public_ip"=> instance.public_ip_address, - "root_block_device.#"=> root_block_devices_in(block_devices, instance).length.to_s, - "security_groups.#"=> in_vpc ? "0" : instance.security_groups.length.to_s, - "source_dest_check"=> instance.source_dest_check.to_s, - "tenancy"=> instance.placement.tenancy, - "vpc_security_group_ids.#"=> in_vpc ? instance.security_groups.length.to_s : "0", + "private_dns" => instance.private_dns_name, + "private_ip" => instance.private_ip_address, + "public_dns" => instance.public_dns_name, + "public_ip" => instance.public_ip_address, + "root_block_device.#" => root_block_devices_in(block_devices, instance).length.to_s, + "security_groups.#" => in_vpc ? "0" : instance.security_groups.length.to_s, + "source_dest_check" => instance.source_dest_check.to_s, + "tenancy" => instance.placement.tenancy, + "vpc_security_group_ids.#" => in_vpc ? instance.security_groups.length.to_s : "0", } placement_group = instance.placement.group_name @@ -72,7 +72,7 @@ def block_device_ids_of(instance) end def block_devices_of(instance) - return [] unless instance.block_device_mappings.length > 0 + return [] if instance.block_device_mappings.empty? @client.describe_volumes(volume_ids: block_device_ids_of(instance)).map(&:volumes).flatten end @@ -92,8 +92,8 @@ def ebs_block_devices_in(block_devices, instance) # https://github.com/hashicorp/terraform/blob/281e4d3e67f66daab9cdb1f7c8b6f602d949e5ee/builtin/providers/aws/resource_aws_instance.go#L481-L501 # def in_vpc?(instance) - vpc_security_groups_of(instance).length > 0 || - (instance.subnet_id && instance.subnet_id != "" && instance.security_groups.length == 0) + !vpc_security_groups_of(instance).empty? || + (instance.subnet_id && instance.subnet_id != "" && instance.security_groups.empty?) end def monitoring_state(instance) diff --git a/lib/terraforming/resource/eip.rb b/lib/terraforming/resource/eip.rb index eb6f17c6..ae153a33 100644 --- a/lib/terraforming/resource/eip.rb +++ b/lib/terraforming/resource/eip.rb @@ -31,7 +31,7 @@ def tfstate "public_ip" => addr.public_ip, "vpc" => is_vpc?(addr).to_s, } - attributes.delete_if{|k, v| v.nil?} + attributes.delete_if { |_k, v| v.nil? } resources["aws_eip.#{addr.allocation_id}"] = { "type" => "aws_eip", "primary" => { diff --git a/lib/terraforming/resource/elasti_cache_cluster.rb b/lib/terraforming/resource/elasti_cache_cluster.rb index eea48231..16038332 100644 --- a/lib/terraforming/resource/elasti_cache_cluster.rb +++ b/lib/terraforming/resource/elasti_cache_cluster.rb @@ -37,9 +37,9 @@ def tfstate } attributes["port"] = if cache_cluster.configuration_endpoint - cache_cluster.configuration_endpoint.port.to_s - else - cache_cluster.cache_nodes[0].endpoint.port.to_s + cache_cluster.configuration_endpoint.port.to_s + else + cache_cluster.cache_nodes[0].endpoint.port.to_s end resources["aws_elasticache_cluster.#{cache_cluster.cache_cluster_id}"] = { @@ -61,7 +61,7 @@ def cache_clusters end def cluster_in_vpc?(cache_cluster) - cache_cluster.cache_security_groups.length == 0 + cache_cluster.cache_security_groups.empty? end def security_group_ids_of(cache_cluster) diff --git a/lib/terraforming/resource/elb.rb b/lib/terraforming/resource/elb.rb index eea3b4da..add2ee9f 100644 --- a/lib/terraforming/resource/elb.rb +++ b/lib/terraforming/resource/elb.rb @@ -48,7 +48,6 @@ def tfstate attributes.merge!(instances_attributes_of(load_balancer)) attributes.merge!(tags_attributes_of(load_balancer)) - resources["aws_elb.#{module_name_of(load_balancer)}"] = { "type" => "aws_elb", "primary" => { @@ -106,7 +105,7 @@ def healthcheck_hashcode_of(health_check) def tags_attributes_of(elb) tags = @client.describe_tags(load_balancer_names: [elb.load_balancer_name]).tag_descriptions.first.tags - attributes = {"tags.#" => tags.length.to_s} + attributes = { "tags.#" => tags.length.to_s } tags.each do |tag| attributes["tags.#{tag.key}"] = tag.value @@ -116,7 +115,7 @@ def tags_attributes_of(elb) end def instances_attributes_of(elb) - attributes = {"instances.#" => elb.instances.length.to_s} + attributes = { "instances.#" => elb.instances.length.to_s } elb.instances.each do |instance| attributes["instances.#{Zlib.crc32(instance.instance_id)}"] = instance.instance_id @@ -126,7 +125,7 @@ def instances_attributes_of(elb) end def subnets_attributes_of(elb) - attributes = {"subnets.#" => elb.subnets.length.to_s} + attributes = { "subnets.#" => elb.subnets.length.to_s } elb.subnets.each do |subnet_id| attributes["subnets.#{Zlib.crc32(subnet_id)}"] = subnet_id @@ -136,7 +135,7 @@ def subnets_attributes_of(elb) end def sg_attributes_of(elb) - attributes = {"security_groups.#" => elb.security_groups.length.to_s} + attributes = { "security_groups.#" => elb.security_groups.length.to_s } elb.security_groups.each do |sg_id| attributes["security_groups.#{Zlib.crc32(sg_id)}"] = sg_id @@ -146,7 +145,7 @@ def sg_attributes_of(elb) end def listeners_attributes_of(elb) - attributes = {"listener.#" => elb.listener_descriptions.length.to_s} + attributes = { "listener.#" => elb.listener_descriptions.length.to_s } elb.listener_descriptions.each do |listener_description| attributes.merge!(listener_attributes_of(listener_description.listener)) diff --git a/lib/terraforming/resource/iam_group.rb b/lib/terraforming/resource/iam_group.rb index 6fc05186..8f576ccf 100644 --- a/lib/terraforming/resource/iam_group.rb +++ b/lib/terraforming/resource/iam_group.rb @@ -22,7 +22,7 @@ def tf def tfstate iam_groups.inject({}) do |resources, group| attributes = { - "arn"=> group.arn, + "arn" => group.arn, "id" => group.group_name, "name" => group.group_name, "path" => group.path, diff --git a/lib/terraforming/resource/iam_group_membership.rb b/lib/terraforming/resource/iam_group_membership.rb index a03a4f24..8a6bd6f8 100644 --- a/lib/terraforming/resource/iam_group_membership.rb +++ b/lib/terraforming/resource/iam_group_membership.rb @@ -24,7 +24,7 @@ def tfstate membership_name = membership_name_of(group) attributes = { - "group"=> group.group_name, + "group" => group.group_name, "id" => membership_name, "name" => membership_name, "users.#" => group_members_of(group).length.to_s, diff --git a/lib/terraforming/resource/iam_policy_attachment.rb b/lib/terraforming/resource/iam_policy_attachment.rb index 5db7a377..606d9cb8 100644 --- a/lib/terraforming/resource/iam_policy_attachment.rb +++ b/lib/terraforming/resource/iam_policy_attachment.rb @@ -60,7 +60,7 @@ def entities_for_policy(policy) result.policy_users += resp.policy_users result.policy_roles += resp.policy_roles end - + result end diff --git a/lib/terraforming/resource/iam_user.rb b/lib/terraforming/resource/iam_user.rb index 658a6c94..4e157f4c 100644 --- a/lib/terraforming/resource/iam_user.rb +++ b/lib/terraforming/resource/iam_user.rb @@ -22,7 +22,7 @@ def tf def tfstate iam_users.inject({}) do |resources, user| attributes = { - "arn"=> user.arn, + "arn" => user.arn, "id" => user.user_name, "name" => user.user_name, "path" => user.path, diff --git a/lib/terraforming/resource/launch_configuration.rb b/lib/terraforming/resource/launch_configuration.rb index b71c41df..e6d324ed 100644 --- a/lib/terraforming/resource/launch_configuration.rb +++ b/lib/terraforming/resource/launch_configuration.rb @@ -21,7 +21,6 @@ def tf def tfstate launch_configurations.inject({}) do |resources, lc| - attributes = { "name" => lc.launch_configuration_name, "image_id" => lc.image_id, @@ -72,7 +71,7 @@ def root_block_device_count(launch_configuration) end def ebs_block_device?(block_device) - block_device.virtual_name == nil && block_device.ebs + block_device.virtual_name.nil? && block_device.ebs end def ebs_block_device_count(launch_configuration) diff --git a/lib/terraforming/resource/nat_gateway.rb b/lib/terraforming/resource/nat_gateway.rb index 87024d33..cb260803 100644 --- a/lib/terraforming/resource/nat_gateway.rb +++ b/lib/terraforming/resource/nat_gateway.rb @@ -24,7 +24,7 @@ def tfstate next resources if nat_gateway.nat_gateway_addresses.empty? attributes = { - "id" => nat_gateway.nat_gateway_id, + "id" => nat_gateway.nat_gateway_id, "allocation_id" => nat_gateway.nat_gateway_addresses[0].allocation_id, "subnet_id" => nat_gateway.subnet_id, "network_inferface_id" => nat_gateway.nat_gateway_addresses[0].network_interface_id, @@ -43,7 +43,7 @@ def tfstate end end - private + private def nat_gateways @client.describe_nat_gateways.nat_gateways diff --git a/lib/terraforming/resource/network_interface.rb b/lib/terraforming/resource/network_interface.rb index ac6ca139..4dfaa646 100644 --- a/lib/terraforming/resource/network_interface.rb +++ b/lib/terraforming/resource/network_interface.rb @@ -49,7 +49,7 @@ def attachment_of(network_interface) end def private_ips_of(network_interface) - network_interface.private_ip_addresses.map{|addr| addr.private_ip_address } + network_interface.private_ip_addresses.map { |addr| addr.private_ip_address } end def security_groups_of(network_interface) @@ -63,7 +63,6 @@ def module_name_of(network_interface) def network_interfaces @client.describe_network_interfaces.map(&:network_interfaces).flatten end - end end end diff --git a/lib/terraforming/resource/opsworks_custom_layer.rb b/lib/terraforming/resource/opsworks_custom_layer.rb index 03b5de7a..d74db902 100644 --- a/lib/terraforming/resource/opsworks_custom_layer.rb +++ b/lib/terraforming/resource/opsworks_custom_layer.rb @@ -21,7 +21,6 @@ def tf def tfstate stacks.inject({}) do |resources, stack| - stack_layers(stack.stack_id).each do |layer| attributes = { "auto_assign_elastic_ips" => layer.auto_assign_elastic_ips.to_s, @@ -107,13 +106,12 @@ def stacks end def stack_layers(stack_id) - @client.describe_layers({stack_id: stack_id}).layers + @client.describe_layers({ stack_id: stack_id }).layers end def module_name_of(object) normalize_module_name(object.name) end - end end end diff --git a/lib/terraforming/resource/opsworks_stack.rb b/lib/terraforming/resource/opsworks_stack.rb index 3cd63f04..32930df0 100644 --- a/lib/terraforming/resource/opsworks_stack.rb +++ b/lib/terraforming/resource/opsworks_stack.rb @@ -75,7 +75,6 @@ def stacks def module_name_of(stack) normalize_module_name(stack.name) end - end end end diff --git a/lib/terraforming/resource/route53_record.rb b/lib/terraforming/resource/route53_record.rb index 078f7ee2..404cc351 100644 --- a/lib/terraforming/resource/route53_record.rb +++ b/lib/terraforming/resource/route53_record.rb @@ -25,8 +25,8 @@ def tfstate record_id = record_id_of(record, zone_id) attributes = { - "id"=> record_id, - "name"=> name_of(record.name.gsub(/\\052/, '*')), + "id" => record_id, + "name" => name_of(record.name.gsub(/\\052/, '*')), "type" => record.type, "zone_id" => zone_id, } diff --git a/lib/terraforming/resource/route53_zone.rb b/lib/terraforming/resource/route53_zone.rb index e93ed5a7..a87946c7 100644 --- a/lib/terraforming/resource/route53_zone.rb +++ b/lib/terraforming/resource/route53_zone.rb @@ -25,9 +25,9 @@ def tfstate vpc = vpc_of(hosted_zone) attributes = { - "comment"=> comment_of(hosted_zone), - "id"=> zone_id, - "name"=> name_of(hosted_zone), + "comment" => comment_of(hosted_zone), + "id" => zone_id, + "name" => name_of(hosted_zone), "name_servers.#" => name_servers_of(hosted_zone).length.to_s, "tags.#" => tags_of(hosted_zone).length.to_s, "vpc_id" => vpc ? vpc.vpc_id : "", diff --git a/lib/terraforming/resource/route_table.rb b/lib/terraforming/resource/route_table.rb index 2f3d4288..1ef2925c 100644 --- a/lib/terraforming/resource/route_table.rb +++ b/lib/terraforming/resource/route_table.rb @@ -47,8 +47,8 @@ def tfstate def routes_of(route_table) route_table.routes.reject do |route| route.gateway_id.to_s == 'local' || - route.origin.to_s == 'EnableVgwRoutePropagation' || - route.destination_prefix_list_id + route.origin.to_s == 'EnableVgwRoutePropagation' || + route.destination_prefix_list_id end end diff --git a/lib/terraforming/resource/security_group.rb b/lib/terraforming/resource/security_group.rb index dfc6ff65..6e7131b0 100644 --- a/lib/terraforming/resource/security_group.rb +++ b/lib/terraforming/resource/security_group.rb @@ -75,7 +75,7 @@ def group_hashcode_of(group) def module_name_of(security_group) if security_group.vpc_id.nil? - normalize_module_name("#{security_group.group_name}") + normalize_module_name(security_group.group_name.to_s) else normalize_module_name("#{security_group.vpc_id}-#{security_group.group_name}") end @@ -85,7 +85,6 @@ def permission_attributes_of(security_group, permission, type) hashcode = permission_hashcode_of(security_group, permission) security_groups = security_groups_in(permission, security_group).reject { |group_name| group_name == security_group.group_name }.reject { |group_id| group_id == security_group.group_id } - attributes = { "#{type}.#{hashcode}.from_port" => (permission.from_port || 0).to_s, "#{type}.#{hashcode}.to_port" => (permission.to_port || 0).to_s, @@ -140,7 +139,7 @@ def permission_hashcode_of(security_group, permission) "#{permission.from_port || 0}-" << "#{permission.to_port || 0}-" << "#{permission.ip_protocol}-" << - "#{self_referenced_permission?(security_group, permission).to_s}-" + "#{self_referenced_permission?(security_group, permission)}-" permission.ip_ranges.each { |range| string << "#{range.cidr_ip}-" } security_groups_in(permission, security_group).each { |group| string << "#{group}-" } @@ -157,7 +156,7 @@ def security_groups end def security_groups_in(permission, security_group) - permission.user_id_group_pairs.map { |range| + permission.user_id_group_pairs.map do |range| # EC2-Classic, same account if security_group.owner_id == range.user_id && !range.group_name.nil? range.group_name @@ -168,7 +167,7 @@ def security_groups_in(permission, security_group) else "#{range.user_id}/#{range.group_name}" end - } + end end def tags_attributes_of(security_group) diff --git a/lib/terraforming/util.rb b/lib/terraforming/util.rb index 28846fd8..055664a6 100644 --- a/lib/terraforming/util.rb +++ b/lib/terraforming/util.rb @@ -26,6 +26,5 @@ def prettify_policy(document, breakline: false, unescape: false) json.strip end end - end end diff --git a/spec/lib/terraforming/cli_spec.rb b/spec/lib/terraforming/cli_spec.rb index 800b6d9b..0f7509a6 100644 --- a/spec/lib/terraforming/cli_spec.rb +++ b/spec/lib/terraforming/cli_spec.rb @@ -276,7 +276,6 @@ module Terraforming it_behaves_like "CLI examples" end - end context "flush to stdout" do @@ -455,7 +454,7 @@ module Terraforming end context "with --tfstate --merge TFSTATE --overwrite" do - before do + before do @tmp_tfstate = Tempfile.new("tfstate") @tmp_tfstate.write(open(tfstate_fixture_path).read) @tmp_tfstate.flush diff --git a/spec/lib/terraforming/resource/elb_spec.rb b/spec/lib/terraforming/resource/elb_spec.rb index 2b8271cf..b9f0b3ae 100644 --- a/spec/lib/terraforming/resource/elb_spec.rb +++ b/spec/lib/terraforming/resource/elb_spec.rb @@ -160,7 +160,7 @@ module Resource let(:tag_attributes) do [{ tags: [ - {key: 'name', value: 'elb-1'} + { key: 'name', value: 'elb-1' } ] }] end @@ -271,26 +271,26 @@ module Resource "internal" => "false", "name" => "hoge", "source_security_group" => "default", - "health_check.#" =>"1", - "health_check.362345074.healthy_threshold" =>"10", - "health_check.362345074.interval" =>"30", - "health_check.362345074.target" =>"HTTP:8080/status", - "health_check.362345074.timeout" =>"5", - "health_check.362345074.unhealthy_threshold" =>"2", - "listener.#" =>"1", + "health_check.#" => "1", + "health_check.362345074.healthy_threshold" => "10", + "health_check.362345074.interval" => "30", + "health_check.362345074.target" => "HTTP:8080/status", + "health_check.362345074.timeout" => "5", + "health_check.362345074.unhealthy_threshold" => "2", + "listener.#" => "1", "listener.3051874140.instance_port" => "80", "listener.3051874140.instance_protocol" => "http", "listener.3051874140.lb_port" => "443", "listener.3051874140.lb_protocol" => "https", - "listener.3051874140.ssl_certificate_id" => "arn:aws:iam::123456789012:server-certificate/foobar", "security_groups.#" =>"2", + "listener.3051874140.ssl_certificate_id" => "arn:aws:iam::123456789012:server-certificate/foobar", "security_groups.#" => "2", "security_groups.550527283" => "sg-1234abcd", "security_groups.3942994537" => "sg-5678efgh", - "subnets.#" =>"2", + "subnets.#" => "2", "subnets.3229571749" => "subnet-1234abcd", "subnets.195717631" => "subnet-5678efgh", "instances.3520380136" => "i-1234abcd", - "tags.#" =>"1", - "tags.name" =>"elb-1" + "tags.#" => "1", + "tags.name" => "elb-1" } } }, @@ -314,27 +314,28 @@ module Resource "internal" => "true", "name" => "fuga", "source_security_group" => "elb", - "health_check.#" =>"1", - "health_check.362345074.healthy_threshold" =>"10", - "health_check.362345074.interval" =>"30", - "health_check.362345074.target" =>"HTTP:8080/status", - "health_check.362345074.timeout" =>"5", - "health_check.362345074.unhealthy_threshold" =>"2", - "listener.#" =>"1", - "listener.1674021574.instance_port" =>"80", - "listener.1674021574.instance_protocol" =>"http", - "listener.1674021574.lb_port" =>"443", - "listener.1674021574.lb_protocol" =>"https", - "listener.1674021574.ssl_certificate_id" =>"arn:aws:iam::345678901234:server-certificate/foobar", - "security_groups.#" =>"2", - "security_groups.2877768809" =>"sg-9012ijkl", - "security_groups.1478442660" =>"sg-3456mnop", - "subnets.#" =>"2", - "subnets.1260945407" =>"subnet-9012ijkl", - "subnets.3098543410" =>"subnet-3456mnop", - "instances.436309938" =>"i-5678efgh", - "tags.#" =>"1", - "tags.name" =>"elb-1" } + "health_check.#" => "1", + "health_check.362345074.healthy_threshold" => "10", + "health_check.362345074.interval" => "30", + "health_check.362345074.target" => "HTTP:8080/status", + "health_check.362345074.timeout" => "5", + "health_check.362345074.unhealthy_threshold" => "2", + "listener.#" => "1", + "listener.1674021574.instance_port" => "80", + "listener.1674021574.instance_protocol" => "http", + "listener.1674021574.lb_port" => "443", + "listener.1674021574.lb_protocol" => "https", + "listener.1674021574.ssl_certificate_id" => "arn:aws:iam::345678901234:server-certificate/foobar", + "security_groups.#" => "2", + "security_groups.2877768809" => "sg-9012ijkl", + "security_groups.1478442660" => "sg-3456mnop", + "subnets.#" => "2", + "subnets.1260945407" => "subnet-9012ijkl", + "subnets.3098543410" => "subnet-3456mnop", + "instances.436309938" => "i-5678efgh", + "tags.#" => "1", + "tags.name" => "elb-1" +} } } }) diff --git a/spec/lib/terraforming/resource/iam_group_membership_spec.rb b/spec/lib/terraforming/resource/iam_group_membership_spec.rb index 71d38ba3..b453c174 100644 --- a/spec/lib/terraforming/resource/iam_group_membership_spec.rb +++ b/spec/lib/terraforming/resource/iam_group_membership_spec.rb @@ -104,7 +104,7 @@ module Resource "primary" => { "id" => "hoge-group-membership", "attributes" => { - "group"=> "hoge", + "group" => "hoge", "id" => "hoge-group-membership", "name" => "hoge-group-membership", "users.#" => "1", @@ -116,7 +116,7 @@ module Resource "primary" => { "id" => "fuga-group-membership", "attributes" => { - "group"=> "fuga", + "group" => "fuga", "id" => "fuga-group-membership", "name" => "fuga-group-membership", "users.#" => "1", diff --git a/spec/lib/terraforming/resource/iam_group_policy_spec.rb b/spec/lib/terraforming/resource/iam_group_policy_spec.rb index 26062c22..9f2b0309 100644 --- a/spec/lib/terraforming/resource/iam_group_policy_spec.rb +++ b/spec/lib/terraforming/resource/iam_group_policy_spec.rb @@ -44,7 +44,7 @@ module Resource before do client.stub_responses(:list_groups, groups: groups) - client.stub_responses(:list_group_policies, [{ policy_names: %w(hoge_policy)}, { policy_names: %w(fuga_policy) }]) + client.stub_responses(:list_group_policies, [{ policy_names: %w(hoge_policy) }, { policy_names: %w(fuga_policy) }]) client.stub_responses(:get_group_policy, [hoge_policy, fuga_policy]) end diff --git a/spec/lib/terraforming/resource/iam_group_spec.rb b/spec/lib/terraforming/resource/iam_group_spec.rb index 26301de8..20ddd6c9 100644 --- a/spec/lib/terraforming/resource/iam_group_spec.rb +++ b/spec/lib/terraforming/resource/iam_group_spec.rb @@ -63,7 +63,7 @@ module Resource "primary" => { "id" => "hoge", "attributes" => { - "arn"=> "arn:aws:iam::123456789012:group/hoge", + "arn" => "arn:aws:iam::123456789012:group/hoge", "id" => "hoge", "name" => "hoge", "path" => "/", @@ -76,7 +76,7 @@ module Resource "primary" => { "id" => "fuga", "attributes" => { - "arn"=> "arn:aws:iam::345678901234:group/fuga", + "arn" => "arn:aws:iam::345678901234:group/fuga", "id" => "fuga", "name" => "fuga", "path" => "/system/", diff --git a/spec/lib/terraforming/resource/iam_instance_profile_spec.rb b/spec/lib/terraforming/resource/iam_instance_profile_spec.rb index 2d8a8cff..e13e914d 100644 --- a/spec/lib/terraforming/resource/iam_instance_profile_spec.rb +++ b/spec/lib/terraforming/resource/iam_instance_profile_spec.rb @@ -68,7 +68,7 @@ module Resource "primary" => { "id" => "hoge_profile", "attributes" => { - "arn"=> "arn:aws:iam::123456789012:instance-profile/hoge_profile", + "arn" => "arn:aws:iam::123456789012:instance-profile/hoge_profile", "id" => "hoge_profile", "name" => "hoge_profile", "path" => "/", @@ -81,7 +81,7 @@ module Resource "primary" => { "id" => "fuga_profile", "attributes" => { - "arn"=> "arn:aws:iam::345678901234:instance-profile/fuga_profile", + "arn" => "arn:aws:iam::345678901234:instance-profile/fuga_profile", "id" => "fuga_profile", "name" => "fuga_profile", "path" => "/system/", diff --git a/spec/lib/terraforming/resource/iam_policy_attachment_spec.rb b/spec/lib/terraforming/resource/iam_policy_attachment_spec.rb index 9352bc8f..8025957c 100644 --- a/spec/lib/terraforming/resource/iam_policy_attachment_spec.rb +++ b/spec/lib/terraforming/resource/iam_policy_attachment_spec.rb @@ -52,7 +52,7 @@ module Resource let(:entities_for_policy_fuga) do { policy_groups: [ - { group_name: "fuga", group_id: "GRIPSTUVWXYZA89012345" }, + { group_name: "fuga", group_id: "GRIPSTUVWXYZA89012345" }, ], policy_users: [ { user_name: "hoge", user_id: "USEREFGHIJKLMN1234567" }, diff --git a/spec/lib/terraforming/resource/iam_policy_spec.rb b/spec/lib/terraforming/resource/iam_policy_spec.rb index c79d1234..b60f3dcb 100644 --- a/spec/lib/terraforming/resource/iam_policy_spec.rb +++ b/spec/lib/terraforming/resource/iam_policy_spec.rb @@ -57,7 +57,7 @@ module Resource before do client.stub_responses(:get_policy, [{ policy: policies[0] }, { policy: policies[1] }]) client.stub_responses(:list_policies, policies: policies) - client.stub_responses(:get_policy_version, [{ policy_version: hoge_policy_version } , { policy_version: fuga_policy_version }]) + client.stub_responses(:get_policy_version, [{ policy_version: hoge_policy_version }, { policy_version: fuga_policy_version }]) end describe ".tf" do diff --git a/spec/lib/terraforming/resource/iam_role_spec.rb b/spec/lib/terraforming/resource/iam_role_spec.rb index 119ab532..c1cb21f4 100644 --- a/spec/lib/terraforming/resource/iam_role_spec.rb +++ b/spec/lib/terraforming/resource/iam_role_spec.rb @@ -87,7 +87,7 @@ module Resource "primary" => { "id" => "hoge_role", "attributes" => { - "arn"=> "arn:aws:iam::123456789012:role/hoge_role", + "arn" => "arn:aws:iam::123456789012:role/hoge_role", "assume_role_policy" => "{\n \"Version\": \"2008-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"\",\n \"Effect\": \"Allow\",\n \"Principal\": {\n \"Service\": \"ec2.amazonaws.com\"\n },\n \"Action\": \"sts:AssumeRole\"\n }\n ]\n}\n", "id" => "hoge_role", "name" => "hoge_role", @@ -101,7 +101,7 @@ module Resource "primary" => { "id" => "fuga_role", "attributes" => { - "arn"=> "arn:aws:iam::345678901234:role/fuga_role", + "arn" => "arn:aws:iam::345678901234:role/fuga_role", "assume_role_policy" => "{\n \"Version\": \"2008-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"1\",\n \"Effect\": \"Allow\",\n \"Principal\": {\n \"Service\": \"elastictranscoder.amazonaws.com\"\n },\n \"Action\": \"sts:AssumeRole\"\n }\n ]\n}\n", "id" => "fuga_role", "name" => "fuga_role", diff --git a/spec/lib/terraforming/resource/iam_user_policy_spec.rb b/spec/lib/terraforming/resource/iam_user_policy_spec.rb index 3f058b7b..0076b7aa 100644 --- a/spec/lib/terraforming/resource/iam_user_policy_spec.rb +++ b/spec/lib/terraforming/resource/iam_user_policy_spec.rb @@ -46,7 +46,7 @@ module Resource before do client.stub_responses(:list_users, users: users) - client.stub_responses(:list_user_policies, [{ policy_names: %w(hoge_policy)}, { policy_names: %w(fuga_policy) }]) + client.stub_responses(:list_user_policies, [{ policy_names: %w(hoge_policy) }, { policy_names: %w(fuga_policy) }]) client.stub_responses(:get_user_policy, [hoge_policy, fuga_policy]) end diff --git a/spec/lib/terraforming/resource/iam_user_spec.rb b/spec/lib/terraforming/resource/iam_user_spec.rb index 365f4e41..50671c60 100644 --- a/spec/lib/terraforming/resource/iam_user_spec.rb +++ b/spec/lib/terraforming/resource/iam_user_spec.rb @@ -57,7 +57,7 @@ module Resource "primary" => { "id" => "hoge", "attributes" => { - "arn"=> "arn:aws:iam::123456789012:user/hoge", + "arn" => "arn:aws:iam::123456789012:user/hoge", "id" => "hoge", "name" => "hoge", "path" => "/", @@ -70,7 +70,7 @@ module Resource "primary" => { "id" => "fuga.piyo", "attributes" => { - "arn"=> "arn:aws:iam::345678901234:user/fuga", + "arn" => "arn:aws:iam::345678901234:user/fuga", "id" => "fuga.piyo", "name" => "fuga.piyo", "path" => "/system/", diff --git a/spec/lib/terraforming/resource/nat_gateway_spec.rb b/spec/lib/terraforming/resource/nat_gateway_spec.rb index 4a09cf50..80729856 100644 --- a/spec/lib/terraforming/resource/nat_gateway_spec.rb +++ b/spec/lib/terraforming/resource/nat_gateway_spec.rb @@ -61,7 +61,7 @@ module Resource "primary" => { "id" => "nat-0c5b68b2c4d64e037", "attributes" => { - "id" => "nat-0c5b68b2c4d64e037", + "id" => "nat-0c5b68b2c4d64e037", "allocation_id" => "eipalloc-b02a3c79", "subnet_id" => "subnet-cd5645f7", "network_inferface_id" => "eni-03d4046f", @@ -75,7 +75,7 @@ module Resource "primary" => { "id" => "nat-0c5b68b2c4d64ea12", "attributes" => { - "id" => "nat-0c5b68b2c4d64ea12", + "id" => "nat-0c5b68b2c4d64ea12", "allocation_id" => "eipalloc-a03a3c79", "subnet_id" => "subnet-cd564c9e", "network_inferface_id" => "eni-b6e4046f", diff --git a/spec/lib/terraforming/resource/network_interface_spec.rb b/spec/lib/terraforming/resource/network_interface_spec.rb index 3373f0db..5a3c878e 100644 --- a/spec/lib/terraforming/resource/network_interface_spec.rb +++ b/spec/lib/terraforming/resource/network_interface_spec.rb @@ -84,7 +84,7 @@ module Resource instance_id: "i-12345678", delete_on_termination: true, attachment_id: "eni-attach-12345678", - instance_owner_id: "345678901234", + instance_owner_id: "345678901234", }, private_dns_name: "ip-2-2-2-2.ap-northeast-1.compute.internal", availability_zone: "ap-northeast-1a", diff --git a/spec/lib/terraforming/resource/route53_record_spec.rb b/spec/lib/terraforming/resource/route53_record_spec.rb index 27ae373f..f6b50691 100644 --- a/spec/lib/terraforming/resource/route53_record_spec.rb +++ b/spec/lib/terraforming/resource/route53_record_spec.rb @@ -83,7 +83,7 @@ module Resource before do client.stub_responses(:list_hosted_zones, - hosted_zones: hosted_zones, marker: "", is_truncated: false, max_items: 1) + hosted_zones: hosted_zones, marker: "", is_truncated: false, max_items: 1) client.stub_responses(:list_resource_record_sets, [ { resource_record_sets: hoge_resource_record_sets, is_truncated: false, max_items: 1 }, { resource_record_sets: fuga_resource_record_sets, is_truncated: false, max_items: 1 }, @@ -137,7 +137,7 @@ module Resource "type" => "aws_route53_record", "primary" => { "id" => "ABCDEFGHIJKLMN_hoge.net_A", - "attributes"=> { + "attributes" => { "id" => "ABCDEFGHIJKLMN_hoge.net_A", "name" => "hoge.net", "type" => "A", @@ -167,7 +167,7 @@ module Resource "type" => "aws_route53_record", "primary" => { "id" => "CDEFGHIJKLMNOP_*.example.net_CNAME", - "attributes"=> { + "attributes" => { "id" => "CDEFGHIJKLMNOP_*.example.net_CNAME", "name" => "*.example.net", "type" => "CNAME", diff --git a/spec/lib/terraforming/resource/route53_zone_spec.rb b/spec/lib/terraforming/resource/route53_zone_spec.rb index e6f30166..83f2f757 100644 --- a/spec/lib/terraforming/resource/route53_zone_spec.rb +++ b/spec/lib/terraforming/resource/route53_zone_spec.rb @@ -71,7 +71,7 @@ module Resource before do client.stub_responses(:list_hosted_zones, - hosted_zones: hosted_zones, marker: "", is_truncated: false, max_items: 1) + hosted_zones: hosted_zones, marker: "", is_truncated: false, max_items: 1) client.stub_responses(:list_tags_for_resource, [ { resource_tag_set: hoge_resource_tag_set }, { resource_tag_set: fuga_resource_tag_set }, @@ -112,14 +112,14 @@ module Resource describe ".tfstate" do it "should generate tfstate" do expect(described_class.tfstate(client: client)).to eq({ - "aws_route53_zone.hoge-net-public"=> { - "type"=> "aws_route53_zone", - "primary"=> { - "id"=> "ABCDEFGHIJKLMN", - "attributes"=> { - "comment"=> "", - "id"=> "ABCDEFGHIJKLMN", - "name"=> "hoge.net", + "aws_route53_zone.hoge-net-public" => { + "type" => "aws_route53_zone", + "primary" => { + "id" => "ABCDEFGHIJKLMN", + "attributes" => { + "comment" => "", + "id" => "ABCDEFGHIJKLMN", + "name" => "hoge.net", "name_servers.#" => "4", "tags.#" => "1", "vpc_id" => "", @@ -128,14 +128,14 @@ module Resource }, } }, - "aws_route53_zone.fuga-net-private"=> { - "type"=> "aws_route53_zone", - "primary"=> { - "id"=> "OPQRSTUVWXYZAB", - "attributes"=> { - "comment"=> "fuga.net zone comment", - "id"=> "OPQRSTUVWXYZAB", - "name"=> "fuga.net", + "aws_route53_zone.fuga-net-private" => { + "type" => "aws_route53_zone", + "primary" => { + "id" => "OPQRSTUVWXYZAB", + "attributes" => { + "comment" => "fuga.net zone comment", + "id" => "OPQRSTUVWXYZAB", + "name" => "fuga.net", "name_servers.#" => "0", "tags.#" => "1", "vpc_id" => "vpc-1234abcd", diff --git a/spec/lib/terraforming/resource/route_table_association_spec.rb b/spec/lib/terraforming/resource/route_table_association_spec.rb index 4cd2d95f..9b3ff907 100644 --- a/spec/lib/terraforming/resource/route_table_association_spec.rb +++ b/spec/lib/terraforming/resource/route_table_association_spec.rb @@ -146,7 +146,7 @@ module Resource "aws_route_table_association.my-route-table-rtbassoc-e789012fg" => { "type" => "aws_route_table_association", "primary" => { - "id"=>"rtbassoc-e789012fg", + "id" => "rtbassoc-e789012fg", "attributes" => { "id" => "rtbassoc-e789012fg", "route_table_id" => "rtb-a12bcd34", diff --git a/spec/lib/terraforming/resource/route_table_spec.rb b/spec/lib/terraforming/resource/route_table_spec.rb index 72e2c351..00335ed0 100644 --- a/spec/lib/terraforming/resource/route_table_spec.rb +++ b/spec/lib/terraforming/resource/route_table_spec.rb @@ -187,7 +187,7 @@ module Resource "vpc_id" => "vpc-ab123cde", "tags.#" => "1", - "tags.Name"=>"my-route-table", + "tags.Name" => "my-route-table", "route.#" => "3", "route.4066406027.cidr_block" => "0.0.0.0/0", @@ -216,13 +216,13 @@ module Resource "aws_route_table.my-route-table-2" => { "type" => "aws_route_table", "primary" => { - "id"=>"rtb-efgh5678", + "id" => "rtb-efgh5678", "attributes" => { "id" => "rtb-efgh5678", "vpc_id" => "vpc-ab123cde", "tags.#" => "1", - "tags.Name"=>"my-route-table-2", + "tags.Name" => "my-route-table-2", "route.#" => "1", "route.4031521715.cidr_block" => "0.0.0.0/0", diff --git a/spec/lib/terraforming/resource/s3_spec.rb b/spec/lib/terraforming/resource/s3_spec.rb index 7f27b393..755ce5b8 100644 --- a/spec/lib/terraforming/resource/s3_spec.rb +++ b/spec/lib/terraforming/resource/s3_spec.rb @@ -20,7 +20,7 @@ module Resource ] end - let(:owner) do + let(:owner) do { display_name: "owner", id: "12345678abcdefgh12345678abcdefgh12345678abcdefgh12345678abcdefgh" diff --git a/spec/lib/terraforming/resource/vpc_spec.rb b/spec/lib/terraforming/resource/vpc_spec.rb index 051d20dc..665d9b91 100644 --- a/spec/lib/terraforming/resource/vpc_spec.rb +++ b/spec/lib/terraforming/resource/vpc_spec.rb @@ -45,7 +45,7 @@ module Resource attr_stub_responses = [] - %w(vpc-1234abcd vpc-5678efgh).each do |vpc_id| + %w(vpc-1234abcd vpc-5678efgh).each do |_vpc_id| %i(enable_dns_hostnames enable_dns_support).each do |attr| attr_stub_responses << { attr => { value: true } } end