Use built-in schema.HashString.

This commit is contained in:
Trevor Pounds 2016-02-07 15:51:26 -08:00
parent 2baff8ad22
commit 0cd0ff0f8e
22 changed files with 36 additions and 120 deletions

View File

@ -5,7 +5,6 @@ import (
"regexp"
"github.com/hashicorp/atlas-go/v1"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
)
@ -51,9 +50,7 @@ func resourceArtifact() *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,
},
"metadata": &schema.Schema{

View File

@ -1,7 +1,6 @@
package aws
import (
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/mutexkv"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
@ -73,9 +72,7 @@ func Provider() terraform.ResourceProvider {
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
ConflictsWith: []string{"forbidden_account_ids"},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: schema.HashString,
},
"forbidden_account_ids": &schema.Schema{
@ -83,9 +80,7 @@ func Provider() terraform.ResourceProvider {
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
ConflictsWith: []string{"allowed_account_ids"},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: schema.HashString,
},
"dynamodb_endpoint": &schema.Schema{

View File

@ -4,7 +4,6 @@ import (
"fmt"
"log"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
"github.com/aws/aws-sdk-go/aws"
@ -61,9 +60,7 @@ func resourceAwsCloudWatchMetricAlarm() *schema.Resource {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: schema.HashString,
},
"alarm_description": &schema.Schema{
Type: schema.TypeString,
@ -77,17 +74,13 @@ func resourceAwsCloudWatchMetricAlarm() *schema.Resource {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: schema.HashString,
},
"ok_actions": &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,
},
"unit": &schema.Schema{
Type: schema.TypeString,

View File

@ -11,7 +11,6 @@ import (
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/elasticache"
"github.com/aws/aws-sdk-go/service/iam"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
)
@ -89,18 +88,14 @@ func resourceAwsElasticacheCluster() *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,
},
"security_group_ids": &schema.Schema{
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: schema.HashString,
},
// Exported Attributes
"cache_nodes": &schema.Schema{
@ -142,9 +137,7 @@ func resourceAwsElasticacheCluster() *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,
},
"snapshot_window": &schema.Schema{
@ -185,9 +178,7 @@ func resourceAwsElasticacheCluster() *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,
},
"tags": tagsSchema(),

View File

@ -8,7 +8,6 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/elasticache"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
)
@ -35,9 +34,7 @@ func resourceAwsElasticacheSecurityGroup() *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,
},
},
}

View File

@ -9,7 +9,6 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/elasticache"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
)
@ -41,9 +40,7 @@ func resourceAwsElasticacheSubnetGroup() *schema.Resource {
Type: schema.TypeSet,
Required: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: schema.HashString,
},
},
}

View File

@ -117,9 +117,7 @@ func resourceAwsInstance() *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,
},
"public_dns": &schema.Schema{

View File

@ -8,7 +8,6 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/elb"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
)
@ -29,9 +28,7 @@ func resourceAwsProxyProtocolPolicy() *schema.Resource {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Required: true,
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: schema.HashString,
},
},
}

View File

@ -34,9 +34,7 @@ func resourceAwsRouteTable() *schema.Resource {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: schema.HashString,
},
"route": &schema.Schema{

View File

@ -106,9 +106,7 @@ func resourceAwsSecurityGroup() *schema.Resource {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: schema.HashString,
},
"self": &schema.Schema{
@ -152,9 +150,7 @@ func resourceAwsSecurityGroup() *schema.Resource {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: schema.HashString,
},
"self": &schema.Schema{

View File

@ -7,7 +7,6 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
)
@ -38,9 +37,7 @@ func resourceAwsVpcEndpoint() *schema.Resource {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: schema.HashString,
},
},
}

View File

@ -85,7 +85,7 @@ func resourceDockerContainer() *schema.Resource {
Optional: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: stringSetHash,
Set: schema.HashString,
},
"publish_all_ports": &schema.Schema{
@ -225,7 +225,7 @@ func resourceDockerContainer() *schema.Resource {
Optional: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: stringSetHash,
Set: schema.HashString,
},
"links": &schema.Schema{
@ -233,7 +233,7 @@ func resourceDockerContainer() *schema.Resource {
Optional: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: stringSetHash,
Set: schema.HashString,
},
"ip_address": &schema.Schema{
@ -339,7 +339,7 @@ func resourceDockerContainer() *schema.Resource {
Optional: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: stringSetHash,
Set: schema.HashString,
},
},
}
@ -407,7 +407,3 @@ func resourceDockerVolumesHash(v interface{}) int {
return hashcode.String(buf.String())
}
func stringSetHash(v interface{}) int {
return hashcode.String(v.(string))
}

View File

@ -51,9 +51,7 @@ func resourceComputeFirewall() *schema.Resource {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: schema.HashString,
},
},
},
@ -64,27 +62,21 @@ func resourceComputeFirewall() *schema.Resource {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: schema.HashString,
},
"source_tags": &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,
},
"target_tags": &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,
},
"self_link": &schema.Schema{

View File

@ -5,19 +5,14 @@ import (
"log"
"strings"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
"google.golang.org/api/compute/v1"
"google.golang.org/api/googleapi"
)
func stringHashcode(v interface{}) int {
return hashcode.String(v.(string))
}
func stringScopeHashcode(v interface{}) int {
v = canonicalizeServiceScope(v.(string))
return hashcode.String(v.(string))
return schema.HashString(v)
}
func resourceComputeInstance() *schema.Resource {
@ -263,7 +258,7 @@ func resourceComputeInstance() *schema.Resource {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: stringHashcode,
Set: schema.HashString,
},
"metadata_fingerprint": &schema.Schema{

View File

@ -8,7 +8,6 @@ import (
"google.golang.org/api/compute/v1"
"google.golang.org/api/googleapi"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
)
@ -82,9 +81,7 @@ func resourceComputeInstanceGroupManager() *schema.Resource {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: schema.HashString,
},
"target_size": &schema.Schema{

View File

@ -4,7 +4,6 @@ import (
"fmt"
"log"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
"google.golang.org/api/compute/v1"
"google.golang.org/api/googleapi"
@ -234,9 +233,7 @@ func resourceComputeInstanceTemplate() *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,
},
"metadata_fingerprint": &schema.Schema{

View File

@ -4,7 +4,6 @@ import (
"fmt"
"log"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
"google.golang.org/api/compute/v1"
"google.golang.org/api/googleapi"
@ -82,9 +81,7 @@ func resourceComputeRoute() *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,
},
"self_link": &schema.Schema{

View File

@ -5,7 +5,6 @@ import (
"log"
"time"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/fwaas/policies"
@ -53,9 +52,7 @@ func resourceFWPolicyV1() *schema.Resource {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: schema.HashString,
},
},
}

View File

@ -97,9 +97,7 @@ func resourceLBPoolV1() *schema.Resource {
Optional: true,
ForceNew: false,
Elem: &schema.Schema{Type: schema.TypeString},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: schema.HashString,
},
},
}

View File

@ -5,7 +5,6 @@ import (
"log"
"time"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
@ -67,9 +66,7 @@ func resourceNetworkingPortV2() *schema.Resource {
ForceNew: false,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: schema.HashString,
},
"device_id": &schema.Schema{
Type: schema.TypeString,

View File

@ -5,7 +5,6 @@ import (
"log"
"time"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
@ -88,9 +87,7 @@ func resourceNetworkingSubnetV2() *schema.Resource {
Optional: true,
ForceNew: false,
Elem: &schema.Schema{Type: schema.TypeString},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: schema.HashString,
},
"host_routes": &schema.Schema{
Type: schema.TypeList,

View File

@ -6,7 +6,6 @@ import (
"github.com/hashicorp/hil/ast"
"github.com/hashicorp/terraform/config"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/terraform"
)
@ -213,9 +212,7 @@ func TestConfigFieldReader_ComputedSet(t *testing.T) {
"strSet": &Schema{
Type: TypeSet,
Elem: &Schema{Type: TypeString},
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
Set: HashString,
},
}