driftctl/enumeration/remote/aws/lambda_event_source_mapping...

47 lines
1.3 KiB
Go
Raw Normal View History

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"
resourceaws "github.com/snyk/driftctl/enumeration/resource/aws"
)
type LambdaEventSourceMappingEnumerator struct {
repository repository.LambdaRepository
factory resource.ResourceFactory
}
func NewLambdaEventSourceMappingEnumerator(repo repository.LambdaRepository, factory resource.ResourceFactory) *LambdaEventSourceMappingEnumerator {
return &LambdaEventSourceMappingEnumerator{
repository: repo,
factory: factory,
}
}
func (e *LambdaEventSourceMappingEnumerator) SupportedType() resource.ResourceType {
return resourceaws.AwsLambdaEventSourceMappingResourceType
}
2021-08-09 14:03:04 +00:00
func (e *LambdaEventSourceMappingEnumerator) Enumerate() ([]*resource.Resource, error) {
eventSourceMappings, err := e.repository.ListAllLambdaEventSourceMappings()
if err != nil {
2021-08-03 10:34:36 +00:00
return nil, remoteerror.NewResourceListingError(err, string(e.SupportedType()))
}
2021-10-27 09:30:47 +00:00
results := make([]*resource.Resource, 0, len(eventSourceMappings))
for _, eventSourceMapping := range eventSourceMappings {
results = append(
results,
e.factory.CreateAbstractResource(
string(e.SupportedType()),
*eventSourceMapping.UUID,
map[string]interface{}{},
),
)
}
return results, err
}