Skip to content

Commit

Permalink
Merge pull request #1633 from Banno/route53-zone-back-to-list
Browse files Browse the repository at this point in the history
changing route53_zone.name_servers back to list
  • Loading branch information
phinze committed Apr 29, 2015
2 parents fa85e6b + fe2d9ea commit 950bd92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
8 changes: 3 additions & 5 deletions builtin/providers/aws/resource_aws_route53_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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)
}
Expand Down
13 changes: 9 additions & 4 deletions builtin/providers/aws/resource_aws_route53_zone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 950bd92

Please sign in to comment.