driftctl/enumeration/remote/aws/api_gateway_vpc_link_enumer...

47 lines
1.2 KiB
Go
Raw Normal View History

2021-10-08 13:31:04 +00:00
package aws
import (
"github.com/snyk/driftctl/enumeration/remote/aws/repository"
remoteerror "github.com/snyk/driftctl/enumeration/remote/error"
"github.com/snyk/driftctl/enumeration/resource"
"github.com/snyk/driftctl/enumeration/resource/aws"
2021-10-08 13:31:04 +00:00
)
type ApiGatewayVpcLinkEnumerator struct {
repository repository.ApiGatewayRepository
factory resource.ResourceFactory
}
func NewApiGatewayVpcLinkEnumerator(repo repository.ApiGatewayRepository, factory resource.ResourceFactory) *ApiGatewayVpcLinkEnumerator {
return &ApiGatewayVpcLinkEnumerator{
repository: repo,
factory: factory,
}
}
func (e *ApiGatewayVpcLinkEnumerator) SupportedType() resource.ResourceType {
return aws.AwsApiGatewayVpcLinkResourceType
}
func (e *ApiGatewayVpcLinkEnumerator) Enumerate() ([]*resource.Resource, error) {
vpcLinks, err := e.repository.ListAllVpcLinks()
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(vpcLinks))
2021-10-08 13:31:04 +00:00
for _, vpcLink := range vpcLinks {
results = append(
results,
e.factory.CreateAbstractResource(
string(e.SupportedType()),
*vpcLink.Id,
map[string]interface{}{},
),
)
}
return results, err
}