-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
DNS: support for private dns zones #1404
Conversation
196082d
to
a71a387
Compare
8c27990
to
4113acc
Compare
4113acc
to
c6a2437
Compare
There was a problem hiding this 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!
azurerm/data_source_dns_zone.go
Outdated
for _, rvn := range *rvns { | ||
registrationVNets = append(registrationVNets, *rvn.ID) | ||
} | ||
if err := d.Set("registration_virtual_networks", registrationVNets); err != nil { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
azurerm/data_source_dns_zone.go
Outdated
if err := d.Set("resolution_virtual_networks", resolutionVNets); err != nil { | ||
return err | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(same here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
vendor/vendor.json
Outdated
"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", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
azurerm/data_source_dns_zone.go
Outdated
Computed: true, | ||
}, | ||
|
||
"registration_virtual_networks": { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
azurerm/data_source_dns_zone.go
Outdated
Elem: &schema.Schema{Type: schema.TypeString}, | ||
}, | ||
|
||
"resolution_virtual_networks": { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea.
There was a problem hiding this comment.
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": { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
azurerm/data_source_dns_zone.go
Outdated
Type: schema.TypeString, | ||
Default: nil, | ||
Optional: true, | ||
Computed: true, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
azurerm/data_source_dns_zone.go
Outdated
Type: schema.TypeList, | ||
Default: nil, | ||
Optional: true, | ||
Computed: true, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
azurerm/data_source_dns_zone.go
Outdated
"resolution_virtual_networks": { | ||
Type: schema.TypeList, | ||
Default: nil, | ||
Optional: true, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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": { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
c6a2437
to
db23bf4
Compare
@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
There was a problem hiding this 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!
azurerm/resource_arm_dns_zone.go
Outdated
|
||
parameters := dns.Zone{ | ||
Location: &location, | ||
Tags: expandTags(tags), | ||
ZoneProperties: &dns.ZoneProperties{ | ||
ZoneType: convertZoneType(zoneType), |
There was a problem hiding this comment.
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),
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
azurerm/resource_arm_dns_zone.go
Outdated
if err := d.Set("resolution_virtual_network_ids", resolutionVirtualNetworks); err != nil { | ||
return err | ||
} | ||
} |
There was a problem hiding this comment.
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?
azurerm/resource_arm_dns_zone.go
Outdated
} | ||
if err := d.Set("registration_virtual_network_ids", registrationVirtualNetworks); err != nil { | ||
return err | ||
} | ||
} |
There was a problem hiding this comment.
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}, | ||
}, |
There was a problem hiding this comment.
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?
azurerm/resource_arm_dns_zone.go
Outdated
} | ||
if err := d.Set("name_servers", nameServers); err != nil { | ||
return err | ||
} | ||
} |
There was a problem hiding this comment.
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, | ||
}) | ||
} |
There was a problem hiding this comment.
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?
@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 :) |
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! |
Fixes #793