go fmt db things

This commit is contained in:
Clint Shryock 2015-04-15 15:02:52 -05:00
parent 470379e7ed
commit df45b2cda8
8 changed files with 54 additions and 54 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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) {
@ -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.")
@ -80,7 +80,7 @@ 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
}
@ -88,7 +88,7 @@ func testAccCheckDBSubnetGroupExists(n string, v *rds.DBSubnetGroup) resource.Te
return fmt.Errorf("DbSubnetGroup not found")
}
*v = *resp.DBSubnetGroups[0]
*v = *resp.DBSubnetGroups[0]
return nil
}

View File

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

View File

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