sorting the name_server entries
This commit is contained in:
parent
6b5138328f
commit
fe2d9ea3cc
|
@ -3,6 +3,7 @@ package aws
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -101,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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package aws
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
|
@ -115,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 idx, ns := range resp.DelegationSet.NameServers {
|
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)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue