remove helper functions, flatten status in the function

This commit is contained in:
Clint Shryock 2015-02-26 15:47:30 -06:00
parent 561e92e65d
commit f453d1863a
3 changed files with 14 additions and 24 deletions

View File

@ -275,9 +275,13 @@ func resourceAwsDbSecurityGroupStateRefreshFunc(
return nil, "", err
}
st := flattenEC2SecurityGroupStatuses(v.EC2SecurityGroups)
ip := flattenIPRangeStatuses(v.IPRanges)
statuses := append(st, ip...)
statuses := make([]string, 0, len(v.EC2SecurityGroups)+len(v.IPRanges))
for _, ec2g := range v.EC2SecurityGroups {
statuses = append(statuses, *ec2g.Status)
}
for _, ips := range v.IPRanges {
statuses = append(statuses, *ips.Status)
}
for _, stat := range statuses {
// Not done

View File

@ -81,9 +81,13 @@ func testAccCheckAWSDBSecurityGroupAttributes(group *rds.DBSecurityGroup) resour
return fmt.Errorf("bad cidr: %#v", group.IPRanges)
}
ipSt := flattenIPRangeStatuses(group.IPRanges)
if ipSt[0] != "authorized" {
return fmt.Errorf("bad status: %#v", ipSt)
statuses := make([]string, 0, len(group.IPRanges))
for _, ips := range group.IPRanges {
statuses = append(statuses, *ips.Status)
}
if statuses[0] != "authorized" {
return fmt.Errorf("bad status: %#v", statuses)
}
if *group.DBSecurityGroupName != "secgroup-terraform" {

View File

@ -207,21 +207,3 @@ func expandStringList(configured []interface{}) []string {
}
return vs
}
// Flattens an array of DBSecurityGroups into a []string
func flattenEC2SecurityGroupStatuses(list []rds.EC2SecurityGroup) []string {
result := make([]string, 0, len(list))
for _, i := range list {
result = append(result, *i.Status)
}
return result
}
// Flattens an array of IPRanges into a []string
func flattenIPRangeStatuses(list []rds.IPRange) []string {
result := make([]string, 0, len(list))
for _, i := range list {
result = append(result, *i.Status)
}
return result
}