From 41ee6d16a48583839c8bd161d4414125a3e99a2b Mon Sep 17 00:00:00 2001 From: Adam Charrett Date: Wed, 17 Jul 2024 19:17:44 +0100 Subject: [PATCH 1/2] awss3receiver: Remove use of deprecated AWS SDK v2 API --- .chloggen/awss3receiver_deprecated_api.yaml | 27 +++++++++++++++++++++ receiver/awss3receiver/s3intf.go | 16 ++++-------- 2 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 .chloggen/awss3receiver_deprecated_api.yaml diff --git a/.chloggen/awss3receiver_deprecated_api.yaml b/.chloggen/awss3receiver_deprecated_api.yaml new file mode 100644 index 0000000000000..781b3b7d81c71 --- /dev/null +++ b/.chloggen/awss3receiver_deprecated_api.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: 'enhancement' + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: awss3receiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "Removal of deprecated AWS SDK v2 API usage." + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [30750] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/receiver/awss3receiver/s3intf.go b/receiver/awss3receiver/s3intf.go index b3b73d5bfd7a5..ed2a869c93d6f 100644 --- a/receiver/awss3receiver/s3intf.go +++ b/receiver/awss3receiver/s3intf.go @@ -37,17 +37,6 @@ func newS3Client(ctx context.Context, cfg S3DownloaderConfig) (ListObjectsAPI, G if cfg.Region != "" { optionsFuncs = append(optionsFuncs, config.WithRegion(cfg.Region)) } - - if cfg.Endpoint != "" { - customResolver := aws.EndpointResolverWithOptionsFunc(func(_, _ string, _ ...any) (aws.Endpoint, error) { - return aws.Endpoint{ - PartitionID: cfg.EndpointPartitionID, - URL: cfg.Endpoint, - SigningRegion: cfg.Region, - }, nil - }) - optionsFuncs = append(optionsFuncs, config.WithEndpointResolverWithOptions(customResolver)) - } awsCfg, err := config.LoadDefaultConfig(ctx, optionsFuncs...) if err != nil { log.Fatalf("unable to load SDK config, %v", err) @@ -59,6 +48,11 @@ func newS3Client(ctx context.Context, cfg S3DownloaderConfig) (ListObjectsAPI, G o.UsePathStyle = true }) } + if cfg.Endpoint != "" { + s3OptionFuncs = append(s3OptionFuncs, func(o *s3.Options) { + o.BaseEndpoint = aws.String(cfg.Endpoint) + }) + } client := s3.NewFromConfig(awsCfg, s3OptionFuncs...) return &s3ListObjectsAPIImpl{client: client}, client, nil From d4a6994547847ea1bd375838b625b6f472d73d13 Mon Sep 17 00:00:00 2001 From: Adam Charrett Date: Sat, 20 Jul 2024 12:33:54 +0100 Subject: [PATCH 2/2] Delete awss3receiver_deprecated_api.yaml --- .chloggen/awss3receiver_deprecated_api.yaml | 27 --------------------- 1 file changed, 27 deletions(-) delete mode 100644 .chloggen/awss3receiver_deprecated_api.yaml diff --git a/.chloggen/awss3receiver_deprecated_api.yaml b/.chloggen/awss3receiver_deprecated_api.yaml deleted file mode 100644 index 781b3b7d81c71..0000000000000 --- a/.chloggen/awss3receiver_deprecated_api.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# Use this changelog template to create an entry for release notes. - -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: 'enhancement' - -# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) -component: awss3receiver - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: "Removal of deprecated AWS SDK v2 API usage." - -# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. -issues: [30750] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: - -# If your change doesn't affect end users or the exported elements of any package, -# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. -# Optional: The change log or logs in which this entry should be included. -# e.g. '[user]' or '[user, api]' -# Include 'user' if the change is relevant to end users. -# Include 'api' if there is a change to a library API. -# Default: '[user]' -change_logs: []