Skip to content

Commit

Permalink
go fmt db things
Browse files Browse the repository at this point in the history
  • Loading branch information
catsby committed Apr 15, 2015
1 parent 470379e commit df45b2c
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 54 deletions.
20 changes: 10 additions & 10 deletions builtin/providers/aws/resource_aws_db_parameter_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"

"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
)

func resourceAwsDbParameterGroup() *schema.Resource {
Expand Down Expand Up @@ -75,7 +75,7 @@ func resourceAwsDbParameterGroup() *schema.Resource {
func resourceAwsDbParameterGroupCreate(d *schema.ResourceData, meta interface{}) error {
rdsconn := meta.(*AWSClient).rdsconn

createOpts := rds.CreateDBParameterGroupInput{
createOpts := rds.CreateDBParameterGroupInput{
DBParameterGroupName: aws.String(d.Get("name").(string)),
DBParameterGroupFamily: aws.String(d.Get("family").(string)),
Description: aws.String(d.Get("description").(string)),
Expand All @@ -102,7 +102,7 @@ func resourceAwsDbParameterGroupCreate(d *schema.ResourceData, meta interface{})
func resourceAwsDbParameterGroupRead(d *schema.ResourceData, meta interface{}) error {
rdsconn := meta.(*AWSClient).rdsconn

describeOpts := rds.DescribeDBParameterGroupsInput{
describeOpts := rds.DescribeDBParameterGroupsInput{
DBParameterGroupName: aws.String(d.Id()),
}

Expand All @@ -121,7 +121,7 @@ func resourceAwsDbParameterGroupRead(d *schema.ResourceData, meta interface{}) e
d.Set("description", describeResp.DBParameterGroups[0].Description)

// Only include user customized parameters as there's hundreds of system/default ones
describeParametersOpts := rds.DescribeDBParametersInput{
describeParametersOpts := rds.DescribeDBParametersInput{
DBParameterGroupName: aws.String(d.Id()),
Source: aws.String("user"),
}
Expand All @@ -131,7 +131,7 @@ func resourceAwsDbParameterGroupRead(d *schema.ResourceData, meta interface{}) e
return err
}

d.Set("parameter", flattenParametersSDK(describeParametersResp.Parameters))
d.Set("parameter", flattenParametersSDK(describeParametersResp.Parameters))

return nil
}
Expand All @@ -154,13 +154,13 @@ func resourceAwsDbParameterGroupUpdate(d *schema.ResourceData, meta interface{})
ns := n.(*schema.Set)

// Expand the "parameter" set to aws-sdk-go compat []rds.Parameter
parameters, err := expandParametersSDK(ns.Difference(os).List())
parameters, err := expandParametersSDK(ns.Difference(os).List())
if err != nil {
return err
}

if len(parameters) > 0 {
modifyOpts := rds.ModifyDBParameterGroupInput{
modifyOpts := rds.ModifyDBParameterGroupInput{
DBParameterGroupName: aws.String(d.Get("name").(string)),
Parameters: parameters,
}
Expand Down Expand Up @@ -198,11 +198,11 @@ func resourceAwsDbParameterGroupDeleteRefreshFunc(

return func() (interface{}, string, error) {

deleteOpts := rds.DeleteDBParameterGroupInput{
deleteOpts := rds.DeleteDBParameterGroupInput{
DBParameterGroupName: aws.String(d.Id()),
}

if _, err := rdsconn.DeleteDBParameterGroup(&deleteOpts); err != nil {
if _, err := rdsconn.DeleteDBParameterGroup(&deleteOpts); err != nil {
rdserr, ok := err.(aws.APIError)
if !ok {
return d, "error", err
Expand Down
10 changes: 5 additions & 5 deletions builtin/providers/aws/resource_aws_db_parameter_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"testing"

"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
Expand Down Expand Up @@ -115,7 +115,7 @@ func testAccCheckAWSDBParameterGroupDestroy(s *terraform.State) error {

// Try to find the Group
resp, err := conn.DescribeDBParameterGroups(
&rds.DescribeDBParameterGroupsInput{
&rds.DescribeDBParameterGroupsInput{
DBParameterGroupName: aws.String(rs.Primary.ID),
})

Expand Down Expand Up @@ -171,7 +171,7 @@ func testAccCheckAWSDBParameterGroupExists(n string, v *rds.DBParameterGroup) re

conn := testAccProvider.Meta().(*AWSClient).rdsconn

opts := rds.DescribeDBParameterGroupsInput{
opts := rds.DescribeDBParameterGroupsInput{
DBParameterGroupName: aws.String(rs.Primary.ID),
}

Expand All @@ -186,7 +186,7 @@ func testAccCheckAWSDBParameterGroupExists(n string, v *rds.DBParameterGroup) re
return fmt.Errorf("DB Parameter Group not found")
}

*v = *resp.DBParameterGroups[0]
*v = *resp.DBParameterGroups[0]

return nil
}
Expand Down
16 changes: 8 additions & 8 deletions builtin/providers/aws/resource_aws_db_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"log"
"time"

"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/multierror"
"github.com/hashicorp/terraform/helper/resource"
Expand Down Expand Up @@ -75,7 +75,7 @@ func resourceAwsDbSecurityGroupCreate(d *schema.ResourceData, meta interface{})
var err error
var errs []error

opts := rds.CreateDBSecurityGroupInput{
opts := rds.CreateDBSecurityGroupInput{
DBSecurityGroupName: aws.String(d.Get("name").(string)),
DBSecurityGroupDescription: aws.String(d.Get("description").(string)),
}
Expand Down Expand Up @@ -164,10 +164,10 @@ func resourceAwsDbSecurityGroupDelete(d *schema.ResourceData, meta interface{})

log.Printf("[DEBUG] DB Security Group destroy: %v", d.Id())

opts := rds.DeleteDBSecurityGroupInput{DBSecurityGroupName: aws.String(d.Id())}
opts := rds.DeleteDBSecurityGroupInput{DBSecurityGroupName: aws.String(d.Id())}

log.Printf("[DEBUG] DB Security Group destroy configuration: %v", opts)
_, err := conn.DeleteDBSecurityGroup(&opts)
_, err := conn.DeleteDBSecurityGroup(&opts)

if err != nil {
newerr, ok := err.(aws.APIError)
Expand All @@ -183,7 +183,7 @@ func resourceAwsDbSecurityGroupDelete(d *schema.ResourceData, meta interface{})
func resourceAwsDbSecurityGroupRetrieve(d *schema.ResourceData, meta interface{}) (*rds.DBSecurityGroup, error) {
conn := meta.(*AWSClient).rdsconn

opts := rds.DescribeDBSecurityGroupsInput{
opts := rds.DescribeDBSecurityGroupsInput{
DBSecurityGroupName: aws.String(d.Id()),
}

Expand All @@ -200,14 +200,14 @@ func resourceAwsDbSecurityGroupRetrieve(d *schema.ResourceData, meta interface{}
return nil, fmt.Errorf("Unable to find DB Security Group: %#v", resp.DBSecurityGroups)
}

return resp.DBSecurityGroups[0], nil
return resp.DBSecurityGroups[0], nil
}

// Authorizes the ingress rule on the db security group
func resourceAwsDbSecurityGroupAuthorizeRule(ingress interface{}, dbSecurityGroupName string, conn *rds.RDS) error {
ing := ingress.(map[string]interface{})

opts := rds.AuthorizeDBSecurityGroupIngressInput{
opts := rds.AuthorizeDBSecurityGroupIngressInput{
DBSecurityGroupName: aws.String(dbSecurityGroupName),
}

Expand Down
10 changes: 5 additions & 5 deletions builtin/providers/aws/resource_aws_db_security_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"testing"

"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
Expand Down Expand Up @@ -47,7 +47,7 @@ func testAccCheckAWSDBSecurityGroupDestroy(s *terraform.State) error {

// Try to find the Group
resp, err := conn.DescribeDBSecurityGroups(
&rds.DescribeDBSecurityGroupsInput{
&rds.DescribeDBSecurityGroupsInput{
DBSecurityGroupName: aws.String(rs.Primary.ID),
})

Expand Down Expand Up @@ -115,7 +115,7 @@ func testAccCheckAWSDBSecurityGroupExists(n string, v *rds.DBSecurityGroup) reso

conn := testAccProvider.Meta().(*AWSClient).rdsconn

opts := rds.DescribeDBSecurityGroupsInput{
opts := rds.DescribeDBSecurityGroupsInput{
DBSecurityGroupName: aws.String(rs.Primary.ID),
}

Expand All @@ -130,7 +130,7 @@ func testAccCheckAWSDBSecurityGroupExists(n string, v *rds.DBSecurityGroup) reso
return fmt.Errorf("DB Security Group not found")
}

*v = *resp.DBSecurityGroups[0]
*v = *resp.DBSecurityGroups[0]

return nil
}
Expand Down
18 changes: 9 additions & 9 deletions builtin/providers/aws/resource_aws_db_subnet_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strings"
"time"

"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
Expand Down Expand Up @@ -49,12 +49,12 @@ func resourceAwsDbSubnetGroupCreate(d *schema.ResourceData, meta interface{}) er
rdsconn := meta.(*AWSClient).rdsconn

subnetIdsSet := d.Get("subnet_ids").(*schema.Set)
subnetIds := make([]*string, subnetIdsSet.Len())
subnetIds := make([]*string, subnetIdsSet.Len())
for i, subnetId := range subnetIdsSet.List() {
subnetIds[i] = aws.String(subnetId.(string))
subnetIds[i] = aws.String(subnetId.(string))
}

createOpts := rds.CreateDBSubnetGroupInput{
createOpts := rds.CreateDBSubnetGroupInput{
DBSubnetGroupName: aws.String(d.Get("name").(string)),
DBSubnetGroupDescription: aws.String(d.Get("description").(string)),
SubnetIDs: subnetIds,
Expand All @@ -74,7 +74,7 @@ func resourceAwsDbSubnetGroupCreate(d *schema.ResourceData, meta interface{}) er
func resourceAwsDbSubnetGroupRead(d *schema.ResourceData, meta interface{}) error {
rdsconn := meta.(*AWSClient).rdsconn

describeOpts := rds.DescribeDBSubnetGroupsInput{
describeOpts := rds.DescribeDBSubnetGroupsInput{
DBSubnetGroupName: aws.String(d.Id()),
}

Expand All @@ -92,7 +92,7 @@ func resourceAwsDbSubnetGroupRead(d *schema.ResourceData, meta interface{}) erro
return fmt.Errorf("Unable to find DB Subnet Group: %#v", describeResp.DBSubnetGroups)
}

var subnetGroup *rds.DBSubnetGroup
var subnetGroup *rds.DBSubnetGroup
for _, s := range describeResp.DBSubnetGroups {
// AWS is down casing the name provided, so we compare lower case versions
// of the names. We lower case both our name and their name in the check,
Expand Down Expand Up @@ -137,11 +137,11 @@ func resourceAwsDbSubnetGroupDeleteRefreshFunc(

return func() (interface{}, string, error) {

deleteOpts := rds.DeleteDBSubnetGroupInput{
deleteOpts := rds.DeleteDBSubnetGroupInput{
DBSubnetGroupName: aws.String(d.Id()),
}

if _, err := rdsconn.DeleteDBSubnetGroup(&deleteOpts); err != nil {
if _, err := rdsconn.DeleteDBSubnetGroup(&deleteOpts); err != nil {
rdserr, ok := err.(aws.APIError)
if !ok {
return d, "error", err
Expand Down
10 changes: 5 additions & 5 deletions builtin/providers/aws/resource_aws_db_subnet_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"

"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
)

func TestAccAWSDBSubnetGroup(t *testing.T) {
Expand Down Expand Up @@ -45,7 +45,7 @@ func testAccCheckDBSubnetGroupDestroy(s *terraform.State) error {

// Try to find the resource
resp, err := conn.DescribeDBSubnetGroups(
&rds.DescribeDBSubnetGroupsInput{DBSubnetGroupName: aws.String(rs.Primary.ID)})
&rds.DescribeDBSubnetGroupsInput{DBSubnetGroupName: aws.String(rs.Primary.ID)})
if err == nil {
if len(resp.DBSubnetGroups) > 0 {
return fmt.Errorf("still exist.")
Expand Down Expand Up @@ -80,15 +80,15 @@ func testAccCheckDBSubnetGroupExists(n string, v *rds.DBSubnetGroup) resource.Te

conn := testAccProvider.Meta().(*AWSClient).rdsconn
resp, err := conn.DescribeDBSubnetGroups(
&rds.DescribeDBSubnetGroupsInput{DBSubnetGroupName: aws.String(rs.Primary.ID)})
&rds.DescribeDBSubnetGroupsInput{DBSubnetGroupName: aws.String(rs.Primary.ID)})
if err != nil {
return err
}
if len(resp.DBSubnetGroups) == 0 {
return fmt.Errorf("DbSubnetGroup not found")
}

*v = *resp.DBSubnetGroups[0]
*v = *resp.DBSubnetGroups[0]

return nil
}
Expand Down
18 changes: 9 additions & 9 deletions builtin/providers/aws/tagsRDS.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package aws
import (
"log"

"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/hashicorp/terraform/helper/schema"
)

Expand All @@ -20,12 +20,12 @@ func setTagsRDS(conn *rds.RDS, d *schema.ResourceData, arn string) error {
// Set tags
if len(remove) > 0 {
log.Printf("[DEBUG] Removing tags: %#v", remove)
k := make([]*string, len(remove), len(remove))
k := make([]*string, len(remove), len(remove))
for i, t := range remove {
k[i] = t.Key
k[i] = t.Key
}

_, err := conn.RemoveTagsFromResource(&rds.RemoveTagsFromResourceInput{
_, err := conn.RemoveTagsFromResource(&rds.RemoveTagsFromResourceInput{
ResourceName: aws.String(arn),
TagKeys: k,
})
Expand All @@ -35,7 +35,7 @@ func setTagsRDS(conn *rds.RDS, d *schema.ResourceData, arn string) error {
}
if len(create) > 0 {
log.Printf("[DEBUG] Creating tags: %#v", create)
_, err := conn.AddTagsToResource(&rds.AddTagsToResourceInput{
_, err := conn.AddTagsToResource(&rds.AddTagsToResourceInput{
ResourceName: aws.String(arn),
Tags: create,
})
Expand All @@ -59,7 +59,7 @@ func diffTagsRDS(oldTags, newTags []*rds.Tag) ([]*rds.Tag, []*rds.Tag) {
}

// Build the list of what to remove
var remove []*rds.Tag
var remove []*rds.Tag
for _, t := range oldTags {
old, ok := create[*t.Key]
if !ok || old != *t.Value {
Expand All @@ -73,9 +73,9 @@ func diffTagsRDS(oldTags, newTags []*rds.Tag) ([]*rds.Tag, []*rds.Tag) {

// tagsFromMap returns the tags for the given map of data.
func tagsFromMapRDS(m map[string]interface{}) []*rds.Tag {
result := make([]*rds.Tag, 0, len(m))
result := make([]*rds.Tag, 0, len(m))
for k, v := range m {
result = append(result, &rds.Tag{
result = append(result, &rds.Tag{
Key: aws.String(k),
Value: aws.String(v.(string)),
})
Expand Down
6 changes: 3 additions & 3 deletions builtin/providers/aws/tagsRDS_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"reflect"
"testing"

"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
Expand Down Expand Up @@ -63,9 +63,9 @@ func TestDiffRDSTags(t *testing.T) {

// testAccCheckTags can be used to check the tags on a resource.
func testAccCheckRDSTags(
ts []*rds.Tag, key string, value string) resource.TestCheckFunc {
ts []*rds.Tag, key string, value string) resource.TestCheckFunc {
return func(s *terraform.State) error {
m := tagsToMapRDS(ts)
m := tagsToMapRDS(ts)
v, ok := m[key]
if value != "" && !ok {
return fmt.Errorf("Missing tag: %s", key)
Expand Down

0 comments on commit df45b2c

Please sign in to comment.