From 56cf1e6faa1bf398e6fc83f0f436f494ead6b16d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 24 Aug 2014 21:50:35 -0700 Subject: [PATCH] Fix go vet complaints --- .../aws/resource_aws_autoscaling_group_test.go | 10 +++++----- builtin/providers/aws/resource_aws_db_instance.go | 3 --- .../providers/aws/resource_aws_db_security_group.go | 5 +---- builtin/providers/aws/resource_aws_eip.go | 8 +++----- .../providers/aws/resource_aws_internet_gateway.go | 2 +- .../aws/resource_aws_launch_configuration.go | 2 -- builtin/providers/aws/resource_aws_security_group.go | 2 +- .../aws/resource_aws_security_group_test.go | 4 +--- builtin/providers/aws/resource_aws_subnet.go | 4 +--- config/loader_hcl.go | 12 ++++++------ helper/diff/resource_builder_test.go | 4 ++-- helper/schema/provider_test.go | 2 +- helper/schema/resource_data.go | 12 ++++++------ helper/schema/schema.go | 2 +- helper/ssh/communicator_test.go | 4 ++-- 15 files changed, 31 insertions(+), 45 deletions(-) diff --git a/builtin/providers/aws/resource_aws_autoscaling_group_test.go b/builtin/providers/aws/resource_aws_autoscaling_group_test.go index 17ede890a..453e5c74c 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group_test.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group_test.go @@ -107,11 +107,11 @@ func testAccCheckAWSAutoScalingGroupAttributes(group *autoscaling.AutoScalingGro } if group.MaxSize != 5 { - return fmt.Errorf("Bad max_size: %s", group.MaxSize) + return fmt.Errorf("Bad max_size: %d", group.MaxSize) } if group.MinSize != 2 { - return fmt.Errorf("Bad max_size: %s", group.MinSize) + return fmt.Errorf("Bad max_size: %d", group.MinSize) } if group.HealthCheckType != "ELB" { @@ -119,15 +119,15 @@ func testAccCheckAWSAutoScalingGroupAttributes(group *autoscaling.AutoScalingGro } if group.HealthCheckGracePeriod != 300 { - return fmt.Errorf("Bad health_check_grace_period: %s", group.HealthCheckGracePeriod) + return fmt.Errorf("Bad health_check_grace_period: %d", group.HealthCheckGracePeriod) } if group.DesiredCapacity != 4 { - return fmt.Errorf("Bad desired_capacity: %s", group.DesiredCapacity) + return fmt.Errorf("Bad desired_capacity: %d", group.DesiredCapacity) } if group.LaunchConfigurationName != "" { - return fmt.Errorf("Bad desired_capacity: %s", group.DesiredCapacity) + return fmt.Errorf("Bad desired_capacity: %d", group.DesiredCapacity) } return nil diff --git a/builtin/providers/aws/resource_aws_db_instance.go b/builtin/providers/aws/resource_aws_db_instance.go index ec31db9f0..a10dace3b 100644 --- a/builtin/providers/aws/resource_aws_db_instance.go +++ b/builtin/providers/aws/resource_aws_db_instance.go @@ -139,10 +139,7 @@ func resource_aws_db_instance_update( s *terraform.ResourceState, d *terraform.ResourceDiff, meta interface{}) (*terraform.ResourceState, error) { - panic("Cannot update DB") - - return nil, nil } func resource_aws_db_instance_destroy( diff --git a/builtin/providers/aws/resource_aws_db_security_group.go b/builtin/providers/aws/resource_aws_db_security_group.go index a23f6a49a..fab93cd72 100644 --- a/builtin/providers/aws/resource_aws_db_security_group.go +++ b/builtin/providers/aws/resource_aws_db_security_group.go @@ -88,10 +88,7 @@ func resource_aws_db_security_group_update( s *terraform.ResourceState, d *terraform.ResourceDiff, meta interface{}) (*terraform.ResourceState, error) { - - panic("Cannot update DB") - - return nil, nil + panic("Cannot update DB security group") } func resource_aws_db_security_group_destroy( diff --git a/builtin/providers/aws/resource_aws_eip.go b/builtin/providers/aws/resource_aws_eip.go index 6d552213d..e27f639a6 100644 --- a/builtin/providers/aws/resource_aws_eip.go +++ b/builtin/providers/aws/resource_aws_eip.go @@ -135,13 +135,11 @@ func resourceAwsEipDelete(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] EIP release (destroy) address allocation: %v", d.Id()) _, err = ec2conn.ReleaseAddress(d.Id()) return err - } else { - log.Printf("[DEBUG] EIP release (destroy) address: %v", d.Id()) - _, err = ec2conn.ReleasePublicAddress(d.Id()) - return err } - return nil + log.Printf("[DEBUG] EIP release (destroy) address: %v", d.Id()) + _, err = ec2conn.ReleasePublicAddress(d.Id()) + return err } func resourceAwsEipRead(d *schema.ResourceData, meta interface{}) error { diff --git a/builtin/providers/aws/resource_aws_internet_gateway.go b/builtin/providers/aws/resource_aws_internet_gateway.go index a21f86d6f..b0a0b9aab 100644 --- a/builtin/providers/aws/resource_aws_internet_gateway.go +++ b/builtin/providers/aws/resource_aws_internet_gateway.go @@ -100,7 +100,7 @@ func resource_aws_internet_gateway_destroy( } if _, err := stateConf.WaitForState(); err != nil { return fmt.Errorf( - "Error waiting for internet gateway (%s) to destroy", + "Error waiting for internet gateway (%s) to destroy: %s", s.ID, err) } diff --git a/builtin/providers/aws/resource_aws_launch_configuration.go b/builtin/providers/aws/resource_aws_launch_configuration.go index a48738dcf..87d97a2ce 100644 --- a/builtin/providers/aws/resource_aws_launch_configuration.go +++ b/builtin/providers/aws/resource_aws_launch_configuration.go @@ -79,8 +79,6 @@ func resource_aws_launch_configuration_update( d *terraform.ResourceDiff, meta interface{}) (*terraform.ResourceState, error) { panic("Update for AWS Launch Configuration is not supported") - - return nil, nil } func resource_aws_launch_configuration_destroy( diff --git a/builtin/providers/aws/resource_aws_security_group.go b/builtin/providers/aws/resource_aws_security_group.go index b160dfddd..efc1e68ee 100644 --- a/builtin/providers/aws/resource_aws_security_group.go +++ b/builtin/providers/aws/resource_aws_security_group.go @@ -88,7 +88,7 @@ func resourceAwsSecurityGroupIngressHash(v interface{}) int { m := v.(map[string]interface{}) buf.WriteString(fmt.Sprintf("%d-", m["from_port"].(int))) buf.WriteString(fmt.Sprintf("%d-", m["to_port"].(int))) - buf.WriteString(fmt.Sprintf("%d-", m["protocol"].(string))) + buf.WriteString(fmt.Sprintf("%s-", m["protocol"].(string))) // We need to make sure to sort the strings below so that we always // generate the same hash code no matter what is in the set. diff --git a/builtin/providers/aws/resource_aws_security_group_test.go b/builtin/providers/aws/resource_aws_security_group_test.go index 281be7a68..e65346180 100644 --- a/builtin/providers/aws/resource_aws_security_group_test.go +++ b/builtin/providers/aws/resource_aws_security_group_test.go @@ -192,11 +192,9 @@ func testAccCheckAWSSecurityGroupExists(n string, group *ec2.SecurityGroupInfo) *group = resp.Groups[0] return nil - } else { - return fmt.Errorf("Security Group not found") } - return nil + return fmt.Errorf("Security Group not found") } } diff --git a/builtin/providers/aws/resource_aws_subnet.go b/builtin/providers/aws/resource_aws_subnet.go index 327666814..b31158cdf 100644 --- a/builtin/providers/aws/resource_aws_subnet.go +++ b/builtin/providers/aws/resource_aws_subnet.go @@ -66,8 +66,6 @@ func resource_aws_subnet_update( // This should never be called because we have no update-able // attributes panic("Update for subnet is not supported") - - return nil, nil } func resource_aws_subnet_destroy( @@ -96,7 +94,7 @@ func resource_aws_subnet_destroy( } if _, err := stateConf.WaitForState(); err != nil { return fmt.Errorf( - "Error waiting for subnet (%s) to destroy", + "Error waiting for subnet (%s) to destroy: %s", s.ID, err) } diff --git a/config/loader_hcl.go b/config/loader_hcl.go index b50b4aa48..380d50294 100644 --- a/config/loader_hcl.go +++ b/config/loader_hcl.go @@ -305,7 +305,7 @@ func loadResourcesHcl(os *hclobj.Object) ([]*Resource, error) { if err := hcl.DecodeObject(&config, obj); err != nil { return nil, fmt.Errorf( "Error reading config for %s[%s]: %s", - t, + t.Key, k, err) } @@ -320,7 +320,7 @@ func loadResourcesHcl(os *hclobj.Object) ([]*Resource, error) { if err != nil { return nil, fmt.Errorf( "Error reading config for %s[%s]: %s", - t, + t.Key, k, err) } @@ -332,7 +332,7 @@ func loadResourcesHcl(os *hclobj.Object) ([]*Resource, error) { if err != nil { return nil, fmt.Errorf( "Error parsing count for %s[%s]: %s", - t, + t.Key, k, err) } @@ -345,7 +345,7 @@ func loadResourcesHcl(os *hclobj.Object) ([]*Resource, error) { if err != nil { return nil, fmt.Errorf( "Error reading depends_on for %s[%s]: %s", - t, + t.Key, k, err) } @@ -358,7 +358,7 @@ func loadResourcesHcl(os *hclobj.Object) ([]*Resource, error) { if err != nil { return nil, fmt.Errorf( "Error reading connection info for %s[%s]: %s", - t, + t.Key, k, err) } @@ -372,7 +372,7 @@ func loadResourcesHcl(os *hclobj.Object) ([]*Resource, error) { if err != nil { return nil, fmt.Errorf( "Error reading provisioners for %s[%s]: %s", - t, + t.Key, k, err) } diff --git a/helper/diff/resource_builder_test.go b/helper/diff/resource_builder_test.go index 4b1f87594..c1c4fdd02 100644 --- a/helper/diff/resource_builder_test.go +++ b/helper/diff/resource_builder_test.go @@ -61,7 +61,7 @@ func TestResourceBuilder_attrSetComputedComplex(t *testing.T) { t.Fatalf("err: %s", err) } if diff != nil { - t.Fatalf("diff shold be nil: %s", diff) + t.Fatalf("diff shold be nil: %#v", diff) } } @@ -361,7 +361,7 @@ func TestResourceBuilder_same(t *testing.T) { t.Fatalf("err: %s", err) } if diff != nil { - t.Fatal("should not diff: %s", diff) + t.Fatalf("should not diff: %#v", diff) } } diff --git a/helper/schema/provider_test.go b/helper/schema/provider_test.go index 1a27b855f..85eb126db 100644 --- a/helper/schema/provider_test.go +++ b/helper/schema/provider_test.go @@ -165,6 +165,6 @@ func TestProviderMeta(t *testing.T) { expected := 42 p.SetMeta(42) if v := p.Meta(); !reflect.DeepEqual(v, expected) { - t.Fatalf("bad: %#v") + t.Fatalf("bad: %#v", v) } } diff --git a/helper/schema/resource_data.go b/helper/schema/resource_data.go index a841e3ba4..fdd8dc11a 100644 --- a/helper/schema/resource_data.go +++ b/helper/schema/resource_data.go @@ -244,7 +244,7 @@ func (d *ResourceData) get( case TypeString: return d.getPrimitive(k, parts, schema, source) default: - panic(fmt.Sprintf("%s: unknown type %s", k, schema.Type)) + panic(fmt.Sprintf("%s: unknown type %#v", k, schema.Type)) } } @@ -570,7 +570,7 @@ func (d *ResourceData) getPrimitive( resultValue = int(v) default: - panic(fmt.Sprintf("Unknown type: %s", schema.Type)) + panic(fmt.Sprintf("Unknown type: %#v", schema.Type)) } return getResult{ @@ -600,7 +600,7 @@ func (d *ResourceData) set( case TypeString: return d.setPrimitive(k, schema, value) default: - panic(fmt.Sprintf("%s: unknown type %s", k, schema.Type)) + panic(fmt.Sprintf("%s: unknown type %#v", k, schema.Type)) } } @@ -773,7 +773,7 @@ func (d *ResourceData) setPrimitive( set = strconv.FormatInt(int64(n), 10) default: - return fmt.Errorf("Unknown type: %s", schema.Type) + return fmt.Errorf("Unknown type: %#v", schema.Type) } d.setMap[k] = set @@ -888,7 +888,7 @@ func (d *ResourceData) statePrimitive( case TypeInt: vs = strconv.FormatInt(int64(v.(int)), 10) default: - panic(fmt.Sprintf("Unknown type: %s", schema.Type)) + panic(fmt.Sprintf("Unknown type: %#v", schema.Type)) } return map[string]string{ @@ -944,6 +944,6 @@ func (d *ResourceData) stateSingle( case TypeString: return d.statePrimitive(prefix, schema) default: - panic(fmt.Sprintf("%s: unknown type %s", prefix, schema.Type)) + panic(fmt.Sprintf("%s: unknown type %#v", prefix, schema.Type)) } } diff --git a/helper/schema/schema.go b/helper/schema/schema.go index b75451c2a..592fc58b9 100644 --- a/helper/schema/schema.go +++ b/helper/schema/schema.go @@ -248,7 +248,7 @@ func (m schemaMap) diff( case TypeSet: err = m.diffSet(k, schema, diff, d) default: - err = fmt.Errorf("%s: unknown type %s", k, schema.Type) + err = fmt.Errorf("%s: unknown type %#v", k, schema.Type) } return err diff --git a/helper/ssh/communicator_test.go b/helper/ssh/communicator_test.go index 53e2f538d..2e16e1482 100644 --- a/helper/ssh/communicator_test.go +++ b/helper/ssh/communicator_test.go @@ -82,10 +82,10 @@ func newMockLineServer(t *testing.T) string { } t.Log("Accepted channel") - go func() { + go func(newChannel ssh.NewChannel) { defer channel.Close() conn.OpenChannel(newChannel.ChannelType(), nil) - }() + }(newChannel) } conn.Close() }()