Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0-dns #5794

Merged
merged 6 commits into from
Feb 18, 2020
Merged

2.0-dns #5794

Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions azurerm/internal/services/dns/data_source_dns_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ func dataSourceArmDnsZone() *schema.Resource {
Set: schema.HashString,
},

"zone_type": {
Type: schema.TypeString,
Computed: true,
Deprecated: "Private DNS Zones are now supported through a separate resource in Azure & Terraform",
},

"registration_virtual_network_ids": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -114,7 +108,6 @@ func dataSourceArmDnsZoneRead(d *schema.ResourceData, meta interface{}) error {
if props := resp.ZoneProperties; props != nil {
d.Set("number_of_record_sets", props.NumberOfRecordSets)
d.Set("max_number_of_record_sets", props.MaxNumberOfRecordSets)
d.Set("zone_type", props.ZoneType)

registrationVNets := make([]string, 0)
if rvns := props.RegistrationVirtualNetworks; rvns != nil {
Expand Down
62 changes: 4 additions & 58 deletions azurerm/internal/services/dns/resource_arm_dns_ns_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,9 @@ func resourceArmDnsNsRecord() *schema.Resource {
},

"records": {
Type: schema.TypeList,
//TODO: add `Required: true` once we remove the `record` attribute
Optional: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
ConflictsWith: []string{"record"},
},

"record": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Deprecated: "This field has been replaced by `records`",
ConflictsWith: []string{"records"},
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"nsdname": {
Type: schema.TypeString,
Required: true,
},
},
},
Type: schema.TypeList,
Required: true,
Elem: &schema.Schema{Type: schema.TypeString},
},

"ttl": {
Expand Down Expand Up @@ -174,11 +155,6 @@ func resourceArmDnsNsRecordRead(d *schema.ResourceData, meta interface{}) error
return fmt.Errorf("Error settings `records`: %+v", err)
}

//TODO: remove this once we remove the `record` attribute
if err := d.Set("record", flattenAzureRmDnsNsRecordsSet(resp.NsRecords)); err != nil {
return fmt.Errorf("Error settings `record`: %+v", err)
}

return tags.FlattenAndSet(d, resp.Metadata)
}

Expand All @@ -204,21 +180,6 @@ func resourceArmDnsNsRecordDelete(d *schema.ResourceData, meta interface{}) erro
return nil
}

//TODO: remove this once we remove the `record` attribute
func flattenAzureRmDnsNsRecordsSet(records *[]dns.NsRecord) []map[string]interface{} {
results := make([]map[string]interface{}, 0, len(*records))

if records != nil {
for _, record := range *records {
nsRecord := make(map[string]interface{})
nsRecord["nsdname"] = *record.Nsdname
results = append(results, nsRecord)
}
}

return results
}

func flattenAzureRmDnsNsRecords(records *[]dns.NsRecord) []string {
results := make([]string, 0, len(*records))

Expand All @@ -234,8 +195,7 @@ func flattenAzureRmDnsNsRecords(records *[]dns.NsRecord) []string {
func expandAzureRmDnsNsRecords(d *schema.ResourceData) *[]dns.NsRecord {
var records []dns.NsRecord

//TODO: remove this once we remove the `record` attribute
if d.HasChange("records") || !d.HasChange("record") {
if d.HasChange("records") {
recordStrings := d.Get("records").([]interface{})
records = make([]dns.NsRecord, len(recordStrings))
for i, v := range recordStrings {
Expand All @@ -247,20 +207,6 @@ func expandAzureRmDnsNsRecords(d *schema.ResourceData) *[]dns.NsRecord {

records[i] = nsRecord
}
} else {
recordList := d.Get("record").(*schema.Set).List()
if len(recordList) != 0 {
records = make([]dns.NsRecord, len(recordList))
for i, v := range recordList {
record := v.(map[string]interface{})
nsdname := record["nsdname"].(string)
nsRecord := dns.NsRecord{
Nsdname: &nsdname,
}

records[i] = nsRecord
}
}
}
return &records
}
15 changes: 0 additions & 15 deletions azurerm/internal/services/dns/resource_arm_dns_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns"
"github.com/hashicorp/go-azure-helpers/response"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients"
Expand Down Expand Up @@ -60,17 +59,6 @@ func resourceArmDnsZone() *schema.Resource {
Set: schema.HashString,
},

"zone_type": {
Type: schema.TypeString,
Default: string(dns.Public),
Optional: true,
Deprecated: "Use the `azurerm_private_dns_zone` resource instead.",
ValidateFunc: validation.StringInSlice([]string{
string(dns.Private),
string(dns.Public),
}, false),
},
tombuildsstuff marked this conversation as resolved.
Show resolved Hide resolved

"registration_virtual_network_ids": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -110,7 +98,6 @@ func resourceArmDnsZoneCreateUpdate(d *schema.ResourceData, meta interface{}) er
}

location := "global"
zoneType := d.Get("zone_type").(string)
t := d.Get("tags").(map[string]interface{})

registrationVirtualNetworkIds := expandDnsZoneRegistrationVirtualNetworkIds(d)
Expand All @@ -120,7 +107,6 @@ func resourceArmDnsZoneCreateUpdate(d *schema.ResourceData, meta interface{}) er
Location: &location,
Tags: tags.Expand(t),
ZoneProperties: &dns.ZoneProperties{
ZoneType: dns.ZoneType(zoneType),
RegistrationVirtualNetworks: registrationVirtualNetworkIds,
ResolutionVirtualNetworks: resolutionVirtualNetworkIds,
},
Expand Down Expand Up @@ -173,7 +159,6 @@ func resourceArmDnsZoneRead(d *schema.ResourceData, meta interface{}) error {
d.Set("resource_group_name", resGroup)
d.Set("number_of_record_sets", resp.NumberOfRecordSets)
d.Set("max_number_of_record_sets", resp.MaxNumberOfRecordSets)
d.Set("zone_type", resp.ZoneType)

registrationVirtualNetworks := flattenDnsZoneRegistrationVirtualNetworkIDs(resp.RegistrationVirtualNetworks)
if err := d.Set("registration_virtual_network_ids", registrationVirtualNetworks); err != nil {
Expand Down
Loading