github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/internal/adapters/cloud/aws/ecs/adapt.go (about) 1 package ecs 2 3 import ( 4 ecsapi "github.com/aws/aws-sdk-go-v2/service/ecs" 5 "github.com/khulnasoft-lab/defsec/internal/adapters/cloud/aws" 6 "github.com/khulnasoft-lab/defsec/pkg/state" 7 ) 8 9 type adapter struct { 10 *aws.RootAdapter 11 api *ecsapi.Client 12 } 13 14 func init() { 15 aws.RegisterServiceAdapter(&adapter{}) 16 } 17 18 func (a *adapter) Provider() string { 19 return "aws" 20 } 21 22 func (a *adapter) Name() string { 23 return "ecs" 24 } 25 26 func (a *adapter) Adapt(root *aws.RootAdapter, state *state.State) error { 27 28 a.RootAdapter = root 29 a.api = ecsapi.NewFromConfig(root.SessionConfig()) 30 var err error 31 32 state.AWS.ECS.TaskDefinitions, err = a.getTaskDefinitions() 33 if err != nil { 34 return err 35 } 36 37 state.AWS.ECS.Clusters, err = a.getClusters() 38 if err != nil { 39 return err 40 } 41 42 return nil 43 }