Fix go vet complaints

This commit is contained in:
Mitchell Hashimoto 2014-08-24 21:50:35 -07:00
parent 2caf33f97f
commit 56cf1e6faa
15 changed files with 31 additions and 45 deletions

View File

@ -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

View File

@ -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(

View File

@ -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(

View File

@ -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 {

View File

@ -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)
}

View File

@ -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(

View File

@ -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.

View File

@ -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")
}
}

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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)
}
}

View File

@ -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)
}
}

View File

@ -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))
}
}

View File

@ -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

View File

@ -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()
}()