-
Notifications
You must be signed in to change notification settings - Fork 149
/
azurerm_privatedns_aaaa_record_enumerator.go
57 lines (47 loc) · 1.59 KB
/
azurerm_privatedns_aaaa_record_enumerator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package azurerm
import (
"github.com/snyk/driftctl/enumeration/remote/azurerm/repository"
remoteerror "github.com/snyk/driftctl/enumeration/remote/error"
"github.com/snyk/driftctl/enumeration/resource"
"github.com/snyk/driftctl/enumeration/resource/azurerm"
)
type AzurermPrivateDNSAAAARecordEnumerator struct {
repository repository.PrivateDNSRepository
factory resource.ResourceFactory
}
func NewAzurermPrivateDNSAAAARecordEnumerator(repo repository.PrivateDNSRepository, factory resource.ResourceFactory) *AzurermPrivateDNSAAAARecordEnumerator {
return &AzurermPrivateDNSAAAARecordEnumerator{
repository: repo,
factory: factory,
}
}
func (e *AzurermPrivateDNSAAAARecordEnumerator) SupportedType() resource.ResourceType {
return azurerm.AzurePrivateDNSAAAARecordResourceType
}
func (e *AzurermPrivateDNSAAAARecordEnumerator) Enumerate() ([]*resource.Resource, error) {
zones, err := e.repository.ListAllPrivateZones()
if err != nil {
return nil, remoteerror.NewResourceListingErrorWithType(err, string(e.SupportedType()), azurerm.AzurePrivateDNSZoneResourceType)
}
results := make([]*resource.Resource, 0)
for _, zone := range zones {
records, err := e.repository.ListAllAAAARecords(zone)
if err != nil {
return nil, remoteerror.NewResourceListingError(err, string(e.SupportedType()))
}
for _, record := range records {
results = append(
results,
e.factory.CreateAbstractResource(
string(e.SupportedType()),
*record.ID,
map[string]interface{}{
"name": *record.Name,
"zone_name": *zone.Name,
},
),
)
}
}
return results, err
}