From e2b27d3538e84957abc62112ca8b22fb56987e97 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 20 Nov 2024 11:24:49 -0600 Subject: [PATCH] fix(aws): update close if aws auth provider is nil (#3607) Signed-off-by: Samantha Coyle Co-authored-by: Yaron Schneider --- bindings/aws/dynamodb/dynamodb.go | 5 ++++- bindings/aws/kinesis/kinesis.go | 5 ++++- bindings/aws/s3/s3.go | 5 ++++- bindings/aws/ses/ses.go | 5 ++++- bindings/aws/sns/sns.go | 5 ++++- bindings/aws/sqs/sqs.go | 5 ++++- pubsub/aws/snssqs/snssqs.go | 5 ++++- secretstores/aws/parameterstore/parameterstore.go | 5 ++++- secretstores/aws/secretmanager/secretmanager.go | 5 ++++- state/aws/dynamodb/dynamodb.go | 5 ++++- 10 files changed, 40 insertions(+), 10 deletions(-) diff --git a/bindings/aws/dynamodb/dynamodb.go b/bindings/aws/dynamodb/dynamodb.go index 755b3158d3..2096f22433 100644 --- a/bindings/aws/dynamodb/dynamodb.go +++ b/bindings/aws/dynamodb/dynamodb.go @@ -122,5 +122,8 @@ func (d *DynamoDB) GetComponentMetadata() (metadataInfo metadata.MetadataMap) { } func (d *DynamoDB) Close() error { - return d.authProvider.Close() + if d.authProvider != nil { + return d.authProvider.Close() + } + return nil } diff --git a/bindings/aws/kinesis/kinesis.go b/bindings/aws/kinesis/kinesis.go index 7ede7ba245..bf684f8bbb 100644 --- a/bindings/aws/kinesis/kinesis.go +++ b/bindings/aws/kinesis/kinesis.go @@ -266,7 +266,10 @@ func (a *AWSKinesis) Close() error { close(a.closeCh) } a.wg.Wait() - return a.authProvider.Close() + if a.authProvider != nil { + return a.authProvider.Close() + } + return nil } func (a *AWSKinesis) ensureConsumer(ctx context.Context, streamARN *string) (*string, error) { diff --git a/bindings/aws/s3/s3.go b/bindings/aws/s3/s3.go index 13f8730e78..fa20c70a6b 100644 --- a/bindings/aws/s3/s3.go +++ b/bindings/aws/s3/s3.go @@ -153,7 +153,10 @@ func (s *AWSS3) Init(ctx context.Context, metadata bindings.Metadata) error { } func (s *AWSS3) Close() error { - return s.authProvider.Close() + if s.authProvider != nil { + return s.authProvider.Close() + } + return nil } func (s *AWSS3) Operations() []bindings.OperationKind { diff --git a/bindings/aws/ses/ses.go b/bindings/aws/ses/ses.go index 4cd752bac5..b8d2ff3faa 100644 --- a/bindings/aws/ses/ses.go +++ b/bindings/aws/ses/ses.go @@ -176,5 +176,8 @@ func (a *AWSSES) GetComponentMetadata() (metadataInfo contribMetadata.MetadataMa } func (a *AWSSES) Close() error { - return a.authProvider.Close() + if a.authProvider != nil { + return a.authProvider.Close() + } + return nil } diff --git a/bindings/aws/sns/sns.go b/bindings/aws/sns/sns.go index 55e3ccefa5..5464f1f044 100644 --- a/bindings/aws/sns/sns.go +++ b/bindings/aws/sns/sns.go @@ -128,5 +128,8 @@ func (a *AWSSNS) GetComponentMetadata() (metadataInfo metadata.MetadataMap) { } func (a *AWSSNS) Close() error { - return a.authProvider.Close() + if a.authProvider != nil { + return a.authProvider.Close() + } + return nil } diff --git a/bindings/aws/sqs/sqs.go b/bindings/aws/sqs/sqs.go index d803bafc5a..b09fde61f6 100644 --- a/bindings/aws/sqs/sqs.go +++ b/bindings/aws/sqs/sqs.go @@ -173,7 +173,10 @@ func (a *AWSSQS) Close() error { close(a.closeCh) } a.wg.Wait() - return a.authProvider.Close() + if a.authProvider != nil { + return a.authProvider.Close() + } + return nil } func (a *AWSSQS) parseSQSMetadata(meta bindings.Metadata) (*sqsMetadata, error) { diff --git a/pubsub/aws/snssqs/snssqs.go b/pubsub/aws/snssqs/snssqs.go index 93481fb733..4e2371764b 100644 --- a/pubsub/aws/snssqs/snssqs.go +++ b/pubsub/aws/snssqs/snssqs.go @@ -875,7 +875,10 @@ func (s *snsSqs) Close() error { s.subscriptionManager.Close() } - return s.authProvider.Close() + if s.authProvider != nil { + return s.authProvider.Close() + } + return nil } func (s *snsSqs) Features() []pubsub.Feature { diff --git a/secretstores/aws/parameterstore/parameterstore.go b/secretstores/aws/parameterstore/parameterstore.go index abf9c6c4de..038399b30c 100644 --- a/secretstores/aws/parameterstore/parameterstore.go +++ b/secretstores/aws/parameterstore/parameterstore.go @@ -182,5 +182,8 @@ func (s *ssmSecretStore) GetComponentMetadata() (metadataInfo metadata.MetadataM } func (s *ssmSecretStore) Close() error { - return s.authProvider.Close() + if s.authProvider != nil { + return s.authProvider.Close() + } + return nil } diff --git a/secretstores/aws/secretmanager/secretmanager.go b/secretstores/aws/secretmanager/secretmanager.go index 6faf1f1eab..979739be5b 100644 --- a/secretstores/aws/secretmanager/secretmanager.go +++ b/secretstores/aws/secretmanager/secretmanager.go @@ -170,5 +170,8 @@ func (s *smSecretStore) GetComponentMetadata() (metadataInfo metadata.MetadataMa } func (s *smSecretStore) Close() error { - return s.authProvider.Close() + if s.authProvider != nil { + return s.authProvider.Close() + } + return nil } diff --git a/state/aws/dynamodb/dynamodb.go b/state/aws/dynamodb/dynamodb.go index ae4ba7c5e9..d3bbd39a85 100644 --- a/state/aws/dynamodb/dynamodb.go +++ b/state/aws/dynamodb/dynamodb.go @@ -275,7 +275,10 @@ func (d *StateStore) GetComponentMetadata() (metadataInfo metadata.MetadataMap) } func (d *StateStore) Close() error { - return d.authProvider.Close() + if d.authProvider != nil { + return d.authProvider.Close() + } + return nil } func (d *StateStore) getDynamoDBMetadata(meta state.Metadata) (*dynamoDBMetadata, error) {