2021-10-04 09:14:29 +00:00
|
|
|
package azurerm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/cloudskiff/driftctl/pkg/remote/azurerm/repository"
|
|
|
|
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
|
|
|
|
"github.com/cloudskiff/driftctl/pkg/resource"
|
|
|
|
"github.com/cloudskiff/driftctl/pkg/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()))
|
|
|
|
}
|
|
|
|
|
2021-10-27 09:30:47 +00:00
|
|
|
results := make([]*resource.Resource, 0, len(resources))
|
2021-10-04 09:14:29 +00:00
|
|
|
|
|
|
|
for _, res := range resources {
|
|
|
|
results = append(
|
|
|
|
results,
|
|
|
|
e.factory.CreateAbstractResource(
|
|
|
|
string(e.SupportedType()),
|
|
|
|
*res.ID,
|
|
|
|
map[string]interface{}{
|
|
|
|
"name": *res.Name,
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
return results, err
|
|
|
|
}
|