Merge commit '33183c0'
* commit '33183c0': Implement a hash function for string sets
This commit is contained in:
commit
7b082d007e
|
@ -6,7 +6,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
||||
|
@ -81,9 +80,7 @@ func resourceAwsAutoscalingGroup() *schema.Resource {
|
|||
Required: true,
|
||||
ForceNew: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
|
||||
"load_balancers": &schema.Schema{
|
||||
|
@ -91,9 +88,7 @@ func resourceAwsAutoscalingGroup() *schema.Resource {
|
|||
Optional: true,
|
||||
ForceNew: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
|
||||
"vpc_zone_identifier": &schema.Schema{
|
||||
|
@ -102,9 +97,7 @@ func resourceAwsAutoscalingGroup() *schema.Resource {
|
|||
Computed: true,
|
||||
ForceNew: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
|
||||
"termination_policies": &schema.Schema{
|
||||
|
@ -113,9 +106,7 @@ func resourceAwsAutoscalingGroup() *schema.Resource {
|
|||
Computed: true,
|
||||
ForceNew: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
|
||||
"tag": autoscalingTagsSchema(),
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"github.com/awslabs/aws-sdk-go/service/iam"
|
||||
"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"
|
||||
)
|
||||
|
@ -132,18 +131,14 @@ func resourceAwsDbInstance() *schema.Resource {
|
|||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
|
||||
"security_group_names": &schema.Schema{
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
|
||||
"final_snapshot_identifier": &schema.Schema{
|
||||
|
@ -372,9 +367,7 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
// Create an empty schema.Set to hold all vpc security group ids
|
||||
ids := &schema.Set{
|
||||
F: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
F: schema.HashString,
|
||||
}
|
||||
for _, v := range v.VPCSecurityGroups {
|
||||
ids.Add(*v.VPCSecurityGroupID)
|
||||
|
@ -383,9 +376,7 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
// Create an empty schema.Set to hold all security group names
|
||||
sgn := &schema.Set{
|
||||
F: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
F: schema.HashString,
|
||||
}
|
||||
for _, v := range v.DBSecurityGroups {
|
||||
sgn.Add(*v.DBSecurityGroupName)
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
"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"
|
||||
)
|
||||
|
@ -37,9 +36,7 @@ func resourceAwsDbSubnetGroup() *schema.Resource {
|
|||
Required: true,
|
||||
ForceNew: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -43,9 +43,7 @@ func resourceAwsElb() *schema.Resource {
|
|||
Optional: true,
|
||||
ForceNew: true,
|
||||
Computed: true,
|
||||
Set: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
|
||||
"instances": &schema.Schema{
|
||||
|
@ -53,9 +51,7 @@ func resourceAwsElb() *schema.Resource {
|
|||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Set: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
|
||||
"security_groups": &schema.Schema{
|
||||
|
@ -63,9 +59,7 @@ func resourceAwsElb() *schema.Resource {
|
|||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Set: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
|
||||
"source_security_group": &schema.Schema{
|
||||
|
@ -80,9 +74,7 @@ func resourceAwsElb() *schema.Resource {
|
|||
Optional: true,
|
||||
ForceNew: true,
|
||||
Computed: true,
|
||||
Set: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
|
||||
"idle_timeout": &schema.Schema{
|
||||
|
|
|
@ -107,9 +107,7 @@ func resourceAwsInstance() *schema.Resource {
|
|||
Computed: true,
|
||||
ForceNew: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
|
||||
"vpc_security_group_ids": &schema.Schema{
|
||||
|
|
|
@ -76,9 +76,7 @@ func resourceAwsLaunchConfiguration() *schema.Resource {
|
|||
Optional: true,
|
||||
ForceNew: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
|
||||
"associate_public_ip_address": &schema.Schema{
|
||||
|
|
|
@ -34,9 +34,7 @@ func resourceAwsNetworkInterface() *schema.Resource {
|
|||
Optional: true,
|
||||
ForceNew: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
|
||||
"security_groups": &schema.Schema{
|
||||
|
@ -44,9 +42,7 @@ func resourceAwsNetworkInterface() *schema.Resource {
|
|||
Optional: true,
|
||||
Computed: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
|
||||
"attachment": &schema.Schema{
|
||||
|
|
|
@ -88,9 +88,7 @@ func resourceAwsRoute53Record() *schema.Resource {
|
|||
ConflictsWith: []string{"alias"},
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Optional: true,
|
||||
Set: func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"github.com/awslabs/aws-sdk-go/service/rds"
|
||||
"github.com/awslabs/aws-sdk-go/service/route53"
|
||||
"github.com/hashicorp/terraform/flatmap"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
|
@ -38,9 +37,7 @@ func testConf() map[string]string {
|
|||
}
|
||||
|
||||
func TestexpandIPPerms(t *testing.T) {
|
||||
hash := func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
}
|
||||
hash := schema.HashString
|
||||
|
||||
expanded := []interface{}{
|
||||
map[string]interface{}{
|
||||
|
@ -121,9 +118,7 @@ func TestexpandIPPerms(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestExpandIPPerms_nonVPC(t *testing.T) {
|
||||
hash := func(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
}
|
||||
hash := schema.HashString
|
||||
|
||||
expanded := []interface{}{
|
||||
map[string]interface{}{
|
||||
|
|
|
@ -5,8 +5,16 @@ import (
|
|||
"reflect"
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
)
|
||||
|
||||
// HashString hashes strings. If you want a Set of strings, this is the
|
||||
// SchemaSetFunc you want.
|
||||
func HashString(v interface{}) int {
|
||||
return hashcode.String(v.(string))
|
||||
}
|
||||
|
||||
// Set is a set data structure that is returned for elements of type
|
||||
// TypeSet.
|
||||
type Set struct {
|
||||
|
|
Loading…
Reference in New Issue