@@ -11,10 +11,8 @@ import (
1111 "github.com/aws/aws-sdk-go-v2/service/sts"
1212 wafv2types "github.com/aws/aws-sdk-go-v2/service/wafv2/types"
1313 "github.com/aws/smithy-go/logging"
14- "github.com/cloudquery/plugin-pb-go/specs"
15- "github.com/cloudquery/plugin-sdk/v3/backend"
16- "github.com/cloudquery/plugin-sdk/v3/plugins/source"
17- "github.com/cloudquery/plugin-sdk/v3/schema"
14+ "github.com/cloudquery/plugin-sdk/v4/schema"
15+ "github.com/cloudquery/plugin-sdk/v4/state"
1816 "github.com/rs/zerolog"
1917 "github.com/thoas/go-funk"
2018 "golang.org/x/sync/errgroup"
@@ -32,7 +30,7 @@ type Client struct {
3230 WAFScope wafv2types.Scope
3331 Partition string
3432 LanguageCode string
35- Backend backend. Backend
33+ Backend state. Client
3634 specificRegions bool
3735 Spec * Spec
3836 // Do not rely on this field, it will be removed once https://github.com/aws/aws-sdk-go-v2/issues/2163 is resolved
@@ -91,9 +89,8 @@ func (s *ServicesManager) InitServicesForPartitionAccount(partition, accountId s
9189 s.services [partition ][accountId ].Regions = funk .UniqString (append (s.services [partition ][accountId ].Regions , svcs .Regions ... ))
9290}
9391
94- func NewAwsClient (logger zerolog.Logger , b backend. Backend , spec * Spec ) Client {
92+ func NewAwsClient (logger zerolog.Logger , spec * Spec ) Client {
9593 return Client {
96- Backend : b ,
9794 ServicesManager : ServicesManager {
9895 services : ServicesPartitionAccountMap {},
9996 },
@@ -122,6 +119,11 @@ func (c *Client) Services() *Services {
122119 return c .ServicesManager .ServicesByPartitionAccount (c .Partition , c .AccountID )
123120}
124121
122+ func (c * Client ) Duplicate () * Client {
123+ duplicateClient := * c
124+ return & duplicateClient
125+ }
126+
125127func (c * Client ) withPartitionAccountIDAndRegion (partition , accountID , region string ) * Client {
126128 return & Client {
127129 Partition : partition ,
@@ -173,21 +175,13 @@ func (c *Client) withLanguageCode(code string) *Client {
173175}
174176
175177// Configure is the entrypoint into configuring the AWS plugin. It is called by the plugin initialization in resources/plugin/aws.go
176- func Configure (ctx context.Context , logger zerolog.Logger , spec specs.Source , opts source.Options ) (schema.ClientMeta , error ) {
177- var awsPluginSpec Spec
178- err := spec .UnmarshalSpec (& awsPluginSpec )
179- if err != nil {
180- return nil , fmt .Errorf ("failed to unmarshal spec: %w" , err )
181- }
182-
183- err = awsPluginSpec .Validate ()
184- if err != nil {
178+ func Configure (ctx context.Context , logger zerolog.Logger , spec Spec ) (schema.ClientMeta , error ) {
179+ if err := spec .Validate (); err != nil {
185180 return nil , fmt .Errorf ("spec validation failed: %w" , err )
186181 }
182+ spec .SetDefaults ()
187183
188- awsPluginSpec .SetDefaults ()
189-
190- client := NewAwsClient (logger , opts .Backend , & awsPluginSpec )
184+ client := NewAwsClient (logger , & spec )
191185
192186 var adminAccountSts AssumeRoleAPIClient
193187
@@ -226,8 +220,7 @@ func Configure(ctx context.Context, logger zerolog.Logger, spec specs.Source, op
226220 return nil
227221 })
228222 }
229- err = errorGroup .Wait ()
230- if err != nil {
223+ if err := errorGroup .Wait (); err != nil {
231224 return nil , err
232225 }
233226
0 commit comments