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

DNS: support for private dns zones #1404

Merged

Conversation

andyliuliming
Copy link
Contributor

@andyliuliming andyliuliming commented Jun 17, 2018

Fixes #793

@stintel
Copy link

stintel commented Jun 18, 2018

Nice. But please get rid of the empty merge commit. I would also suggest to squash
68305e1 and a71a387 and make sure to edit the commit message. Please use correct spelling when doing so. Finally reference in the commit message that it closes #793.

@andyliuliming andyliuliming force-pushed the andliu-private_dns_zones branch 5 times, most recently from 8c27990 to 4113acc Compare June 28, 2018 06:25
@andyliuliming andyliuliming force-pushed the andliu-private_dns_zones branch from 4113acc to c6a2437 Compare June 28, 2018 06:27
@andyliuliming andyliuliming changed the title private dns zones support. Private dns zones support. resolved https://github.com/terraform-providers/terraform-provider-azurerm/issues/793 Jun 28, 2018
@andyliuliming andyliuliming changed the title Private dns zones support. resolved https://github.com/terraform-providers/terraform-provider-azurerm/issues/793 Private dns zones support. resolved #793 Jun 28, 2018
@tombuildsstuff tombuildsstuff self-requested a review June 29, 2018 09:43
Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @andyliuliming

Thanks for this PR - apologies for the delayed review here! I've taken a look through and left some comments in-line, but if we can fix up the comments we should be able to run the tests and get this merged 👍

Thanks!

for _, rvn := range *rvns {
registrationVNets = append(registrationVNets, *rvn.ID)
}
if err := d.Set("registration_virtual_networks", registrationVNets); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to ensure this field's set in all circumstances, so that empty lists are set if it's not present in the response; as such can we make this:

registrationVnets := make([]string, 0)
if rvns := props.RegistrationVirtualNetworks; rvns != nil {
  for _, rvn := range *rvns {
    registrationVNets = append(registrationVNets, *rvn.ID)
  }
}

if err := d.Set("registration_virtual_networks", registrationVNets); err != nil {
  return fmt.Errorf("Error flattening `registration_virtual_networks `: %+v", err)
}

(also can we pull this out into a flatten method to match the other resources)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

if err := d.Set("resolution_virtual_networks", resolutionVNets); err != nil {
return err
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(same here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

"path": "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2017-10-01/dns",
"revision": "7971189ecf5a584b9211f2527737f94bb979644e",
"checksumSHA1": "t6ChlDNU9eaDOo9OgEf/RpWbLZE=",
"path": "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-03-01-preview/dns",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this SDK's actually deprecated - could we switch this out for github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns which is the same but doesn't have the deprecation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Computed: true,
},

"registration_virtual_networks": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is a list of ID's - I think this'd be better as registration_virtual_network_ids

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Elem: &schema.Schema{Type: schema.TypeString},
},

"resolution_virtual_networks": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is a list of ID's - I think this'd be better as resolution_virtual_network_ids

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@@ -43,6 +43,29 @@ func dataSourceArmDnsZone() *schema.Resource {
Set: schema.HashString,
},

"zone_type": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we update the documentation to include these new fields? This is kept in ./website/docs/d/dns_zone.html.markdown

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Type: schema.TypeString,
Default: nil,
Optional: true,
Computed: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is a Data Source this only needs Type: schema.TypeString and Computed: true - can we remove Default/Optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Type: schema.TypeList,
Default: nil,
Optional: true,
Computed: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is a Data Source and these values are returned (and not specified as inputs) - can we remove Default/Optional here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

"resolution_virtual_networks": {
Type: schema.TypeList,
Default: nil,
Optional: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is a Data Source and these values are returned (and not specified as inputs) - can we remove Default/Optional here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@@ -45,6 +45,29 @@ func resourceArmDnsZone() *schema.Resource {
Set: schema.HashString,
},

"zone_type": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(as above) can we document these new fields? The documentation for this new resource can be found in ./website/docs/r/dns_zone.html.markdown

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@tombuildsstuff tombuildsstuff added this to the Soon milestone Jun 29, 2018
@tombuildsstuff tombuildsstuff changed the title Private dns zones support. resolved #793 DNS: support for private dns zones Jun 29, 2018
@andyliuliming andyliuliming force-pushed the andliu-private_dns_zones branch from c6a2437 to db23bf4 Compare July 1, 2018 05:51
@andyliuliming
Copy link
Contributor Author

andyliuliming commented Jul 1, 2018

@tombuildsstuff Thanks Tom for the review. comments resolved. please help review again if it meet your requirements : )

- Switching to use flatten/expand functions
- Making the Resource fields consistent in the docs
- Documenting the new fields in the Data Source
Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @andyliuliming

Thanks for pushing those changes - I've taken a look through and left some minor comments (which I'm going to push a commit for, I hope you don't mind!), but this otherwise LGTM 👍

Thanks!


parameters := dns.Zone{
Location: &location,
Tags: expandTags(tags),
ZoneProperties: &dns.ZoneProperties{
ZoneType: convertZoneType(zoneType),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can switch this out for:

ZoneType: dns.ZoneType(zoneType),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, I don't think so, because we are ignoring the case.
so if customer specify "pRiVaTe" then dns.ZoneType(zoneType) would pass though "pRiVaTe" to the rest api, but azure rest api will refuse that.

Copy link
Contributor

@tombuildsstuff tombuildsstuff Jul 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most of the Azure API's are case insensitive for Enum's, but this one isn't - we can update the field to be strict about the type and then parse this as above

if err := d.Set("resolution_virtual_network_ids", resolutionVirtualNetworks); err != nil {
return err
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we ensure the field resolution_virtual_network_ids is set in either case?

}
if err := d.Set("registration_virtual_network_ids", registrationVirtualNetworks); err != nil {
return err
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we ensure the field registration_virtual_network_ids is set in either case?

Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we document these three fields in the Data Source too?

}
if err := d.Set("name_servers", nameServers); err != nil {
return err
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we split these three out into separate flatten methods?

resolutionVNetSubResources = append(resolutionVNetSubResources, dns.SubResource{
ID: &id,
})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we pull these out into separate expand methods?

@tombuildsstuff tombuildsstuff modified the milestones: Soon, 1.9.0 Jul 2, 2018
@tombuildsstuff
Copy link
Contributor

@andyliuliming just realised I don't have merge permissions to your fork since it's a fork of a fork, have opened andyliuliming#1 with the changes mentioned above (I hope you don't mind!). Once that's merged we should be good to merge this :)

@tombuildsstuff
Copy link
Contributor

DNS Zone tests pass:

screenshot 2018-07-02 at 15 23 24

@ghost
Copy link

ghost commented Mar 30, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Private DNS Preview support ?
3 participants