Merge pull request #1633 from Banno/route53-zone-back-to-list

changing route53_zone.name_servers back to list
This commit is contained in:
Paul Hinze 2015-04-29 10:38:59 -05:00
commit 950bd92837
2 changed files with 12 additions and 9 deletions

View File

@ -3,10 +3,10 @@ package aws
import ( import (
"fmt" "fmt"
"log" "log"
"sort"
"strings" "strings"
"time" "time"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/schema"
@ -34,12 +34,9 @@ func resourceAwsRoute53Zone() *schema.Resource {
}, },
"name_servers": &schema.Schema{ "name_servers": &schema.Schema{
Type: schema.TypeSet, Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString}, Elem: &schema.Schema{Type: schema.TypeString},
Computed: true, Computed: true,
Set: func(v interface{}) int {
return hashcode.String(v.(string))
},
}, },
"tags": tagsSchema(), "tags": tagsSchema(),
@ -105,6 +102,7 @@ func resourceAwsRoute53ZoneRead(d *schema.ResourceData, meta interface{}) error
for i := range zone.DelegationSet.NameServers { for i := range zone.DelegationSet.NameServers {
ns[i] = *zone.DelegationSet.NameServers[i] ns[i] = *zone.DelegationSet.NameServers[i]
} }
sort.Strings(ns)
if err := d.Set("name_servers", ns); err != nil { if err := d.Set("name_servers", ns); err != nil {
return fmt.Errorf("[DEBUG] Error setting name servers for: %s, error: %#v", d.Id(), err) return fmt.Errorf("[DEBUG] Error setting name servers for: %s, error: %#v", d.Id(), err)
} }

View File

@ -2,9 +2,9 @@ package aws
import ( import (
"fmt" "fmt"
"sort"
"testing" "testing"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
@ -116,10 +116,15 @@ func testAccCheckRoute53ZoneExists(n string, zone *route53.HostedZone) resource.
return fmt.Errorf("Hosted zone err: %v", err) return fmt.Errorf("Hosted zone err: %v", err)
} }
for _, ns := range resp.DelegationSet.NameServers { sorted_ns := make([]string, len(resp.DelegationSet.NameServers))
attribute := fmt.Sprintf("name_servers.%d", hashcode.String(*ns)) for i, ns := range resp.DelegationSet.NameServers {
sorted_ns[i] = *ns
}
sort.Strings(sorted_ns)
for idx, ns := range sorted_ns {
attribute := fmt.Sprintf("name_servers.%d", idx)
dsns := rs.Primary.Attributes[attribute] dsns := rs.Primary.Attributes[attribute]
if dsns != *ns { if dsns != ns {
return fmt.Errorf("Got: %v for %v, Expected: %v", dsns, attribute, ns) return fmt.Errorf("Got: %v for %v, Expected: %v", dsns, attribute, ns)
} }
} }