-
Notifications
You must be signed in to change notification settings - Fork 150
/
azurerm_route_table_enumerator.go
48 lines (40 loc) · 1.25 KB
/
azurerm_route_table_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
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 AzurermRouteTableEnumerator struct {
repository repository.NetworkRepository
factory resource.ResourceFactory
}
func NewAzurermRouteTableEnumerator(repo repository.NetworkRepository, factory resource.ResourceFactory) *AzurermRouteTableEnumerator {
return &AzurermRouteTableEnumerator{
repository: repo,
factory: factory,
}
}
func (e *AzurermRouteTableEnumerator) SupportedType() resource.ResourceType {
return azurerm.AzureRouteTableResourceType
}
func (e *AzurermRouteTableEnumerator) Enumerate() ([]*resource.Resource, error) {
resources, err := e.repository.ListAllRouteTables()
if err != nil {
return nil, remoteerror.NewResourceListingError(err, string(e.SupportedType()))
}
results := make([]*resource.Resource, 0, len(resources))
for _, res := range resources {
results = append(
results,
e.factory.CreateAbstractResource(
string(e.SupportedType()),
*res.ID,
map[string]interface{}{
"name": *res.Name,
},
),
)
}
return results, err
}