Azure Plugin: Iterate over all RecordSetListResultPage Pages (#4351)
* Azure Plugin: Iterate over all pages for records Signed-off-by: Manuel Gugger <manuel.gugger@gmail.com> * Azure Plugin: use := for assignment Signed-off-by: Manuel Gugger <manuel.gugger@gmail.com> * Remove unnecessary return param Signed-off-by: Manuel Gugger <manuel.gugger@gmail.com>
This commit is contained in:
parent
51c05679e6
commit
67e90a0656
1 changed files with 9 additions and 13 deletions
|
@ -103,16 +103,18 @@ func (h *Azure) updateZones(ctx context.Context) error {
|
||||||
var err error
|
var err error
|
||||||
var publicSet publicdns.RecordSetListResultPage
|
var publicSet publicdns.RecordSetListResultPage
|
||||||
var privateSet privatedns.RecordSetListResultPage
|
var privateSet privatedns.RecordSetListResultPage
|
||||||
var newZ *file.Zone
|
|
||||||
errs := make([]string, 0)
|
errs := make([]string, 0)
|
||||||
for zName, z := range h.zones {
|
for zName, z := range h.zones {
|
||||||
for i, hostedZone := range z {
|
for i, hostedZone := range z {
|
||||||
|
newZ := file.NewZone(zName, "")
|
||||||
if hostedZone.private {
|
if hostedZone.private {
|
||||||
privateSet, err = h.privateClient.List(ctx, hostedZone.id, hostedZone.zone, nil, "")
|
for privateSet, err = h.privateClient.List(ctx, hostedZone.id, hostedZone.zone, nil, ""); privateSet.NotDone(); err = privateSet.NextWithContext(ctx) {
|
||||||
newZ = updateZoneFromPrivateResourceSet(privateSet, zName)
|
updateZoneFromPrivateResourceSet(privateSet, newZ)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
publicSet, err = h.publicClient.ListByDNSZone(ctx, hostedZone.id, hostedZone.zone, nil, "")
|
for publicSet, err = h.publicClient.ListByDNSZone(ctx, hostedZone.id, hostedZone.zone, nil, ""); publicSet.NotDone(); err = publicSet.NextWithContext(ctx) {
|
||||||
newZ = updateZoneFromPublicResourceSet(publicSet, zName)
|
updateZoneFromPublicResourceSet(publicSet, newZ)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Sprintf("failed to list resource records for %v from azure: %v", hostedZone.zone, err))
|
errs = append(errs, fmt.Sprintf("failed to list resource records for %v from azure: %v", hostedZone.zone, err))
|
||||||
|
@ -131,9 +133,7 @@ func (h *Azure) updateZones(ctx context.Context) error {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateZoneFromPublicResourceSet(recordSet publicdns.RecordSetListResultPage, zName string) *file.Zone {
|
func updateZoneFromPublicResourceSet(recordSet publicdns.RecordSetListResultPage, newZ *file.Zone) {
|
||||||
newZ := file.NewZone(zName, "")
|
|
||||||
|
|
||||||
for _, result := range *(recordSet.Response().Value) {
|
for _, result := range *(recordSet.Response().Value) {
|
||||||
resultFqdn := *(result.RecordSetProperties.Fqdn)
|
resultFqdn := *(result.RecordSetProperties.Fqdn)
|
||||||
resultTTL := uint32(*(result.RecordSetProperties.TTL))
|
resultTTL := uint32(*(result.RecordSetProperties.TTL))
|
||||||
|
@ -217,12 +217,9 @@ func updateZoneFromPublicResourceSet(recordSet publicdns.RecordSetListResultPage
|
||||||
newZ.Insert(cname)
|
newZ.Insert(cname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newZ
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateZoneFromPrivateResourceSet(recordSet privatedns.RecordSetListResultPage, zName string) *file.Zone {
|
func updateZoneFromPrivateResourceSet(recordSet privatedns.RecordSetListResultPage, newZ *file.Zone) {
|
||||||
newZ := file.NewZone(zName, "")
|
|
||||||
|
|
||||||
for _, result := range *(recordSet.Response().Value) {
|
for _, result := range *(recordSet.Response().Value) {
|
||||||
resultFqdn := *(result.RecordSetProperties.Fqdn)
|
resultFqdn := *(result.RecordSetProperties.Fqdn)
|
||||||
resultTTL := uint32(*(result.RecordSetProperties.TTL))
|
resultTTL := uint32(*(result.RecordSetProperties.TTL))
|
||||||
|
@ -298,7 +295,6 @@ func updateZoneFromPrivateResourceSet(recordSet privatedns.RecordSetListResultPa
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return newZ
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServeDNS implements the plugin.Handler interface.
|
// ServeDNS implements the plugin.Handler interface.
|
||||||
|
|
Loading…
Add table
Reference in a new issue