Migrate wizard, downloader, and translator to SDKv2#1995
Migrate wizard, downloader, and translator to SDKv2#1995jefchien merged 2 commits intofeature/aws-sdk-v2from
Conversation
b23ffdc to
3209d8f
Compare
|
|
||
| // seekerLen attempts to get the number of bytes remaining at the seeker's | ||
| // current position. Returns the number of bytes remaining or error. | ||
| func seekerLen(s io.Seeker) (int64, error) { |
There was a problem hiding this comment.
This seems like a fairly generic func (likely stable with no future changes?), but how do we ensure upstream changes are synchronized with this copied version?
There was a problem hiding this comment.
I don't think we need to take upstream changes. There's nothing really AWS SDK specific about this.
| } | ||
| var apiErr smithy.APIError | ||
| if errors.As(err, &apiErr) { | ||
| fmt.Printf("Error code: %s, message: %s\n", apiErr.ErrorCode(), apiErr.ErrorMessage()) |
There was a problem hiding this comment.
is ErrorFault equivalent to original error?
There was a problem hiding this comment.
No. It's an enum indicating whether the error is client-side or server-side.
| fileCreds, err := fileCredentialsProvider.Get() | ||
| fileCredentialsProvider := configaws.RefreshableSharedCredentialsProvider{ | ||
| Profile: "AmazonCloudWatchAgent", | ||
| ExpiryWindow: 10 * time.Minute, |
There was a problem hiding this comment.
should this be a const? also is this the previous window from v1?
There was a problem hiding this comment.
That's a good point. Can make it one. In SDK v1, they never expired (since they're technically static credentials). I can create a separate provider for that where it doesn't mess with the ExpiryWindow stuff.
There was a problem hiding this comment.
same question on the expiry window
| profile, profile_ok := credsMap[commonconfig.CredentialProfile] | ||
| sharedConfigFile, sharedConfigFile_ok := credsMap[commonconfig.CredentialFile] | ||
| if !profile_ok && !sharedConfigFile_ok { | ||
| profile, profileOK := credsMap[commonconfig.CredentialProfile] |
There was a problem hiding this comment.
are these by the new linter or you are pretty much rewriting? 😄
There was a problem hiding this comment.
Little bit of both lol
There was a problem hiding this comment.
are there no unit tests for this file ?
There was a problem hiding this comment.
The SDK didn't have unit tests, but I've added some.
| sharedConfig, err := config.LoadSharedConfigProfile(ctx, p.Profile, func(options *config.LoadSharedConfigOptions) { | ||
| options.CredentialsFiles = []string{p.Filename} | ||
| }) | ||
| var opts []func(*config.LoadSharedConfigOptions) |
There was a problem hiding this comment.
are these just general linter changes outside the scope of the V2 migration ? I like it nonetheless
There was a problem hiding this comment.
This is so the SharedCredentialsProvider can be called with the default filepath.
| fileCreds, err := fileCredentialsProvider.Get() | ||
| fileCredentialsProvider := configaws.RefreshableSharedCredentialsProvider{ | ||
| Profile: "AmazonCloudWatchAgent", | ||
| ExpiryWindow: 10 * time.Minute, |
There was a problem hiding this comment.
same question on the expiry window
Add unit test for seek.
Description of the issue
The last bit of the migration is the tools and utilities used by the wizard, downloader, and translator binaries.
Description of changes
extension/agenthealthseekerLenfunction andreaderSeekerCloserstruct fromgithub.com/aws/aws-sdk-go-v2/feature/s3/manager. This function is no longer exposed by the core package in v2, so this was done to avoid the full import of an S3 package we would otherwise not use.tool/downloadertool/processors/ssmRefreshableSharedCredentialsProviderfrom the credential chain since v2 does not provide an equivalent forcredentials.NewSharedCredentials.tool/utilSDKRegionfunction.DefaultEC2Regionto reuseec2metadataprovidertranslator/util/ec2utilderiveEC2MetadataFromIMDSto reuseec2metadataprovidertranslator/utilSDKRegionWithCredsMapto use SDKv2License
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Tests
Ran unit tests with https://github.com/aws/amazon-cloudwatch-agent/actions/runs/21376946856
Integration test: https://github.com/aws/amazon-cloudwatch-agent/actions/runs/21597922889
Tested wizard to store config in SSM parameter store
Tested downloader to pull config from SSM parameter store
Requirements
Before commiting your code, please do the following steps.
make fmtandmake fmt-shmake lintIntegration Tests
To run integration tests against this PR, add the
ready for testinglabel.