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

View File

@ -2,9 +2,9 @@ package aws
import (
"fmt"
"sort"
"testing"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/resource"
"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)
}
for _, ns := range resp.DelegationSet.NameServers {
attribute := fmt.Sprintf("name_servers.%d", hashcode.String(*ns))
sorted_ns := make([]string, len(resp.DelegationSet.NameServers))
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]
if dsns != *ns {
if dsns != ns {
return fmt.Errorf("Got: %v for %v, Expected: %v", dsns, attribute, ns)
}
}