-
Notifications
You must be signed in to change notification settings - Fork 69
refactor(cli): aws-auth uses modern messaging infrastructure everywhere #292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a weird change, but i think the abstraction was kind of wrong already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't an abstraction, it was a set of factory functions grouped in a namespace 😆
| }; | ||
| } | ||
|
|
||
| public static proxyAgent(options: SdkHttpOptions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pulled out into a separate class. this had otherwise nothing to do with this file
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #292 +/- ##
==========================================
+ Coverage 85.54% 85.62% +0.07%
==========================================
Files 222 223 +1
Lines 36926 37003 +77
Branches 4458 4491 +33
==========================================
+ Hits 31588 31682 +94
+ Misses 5248 5222 -26
- Partials 90 99 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| } | ||
| return fs.readFileSync(filename, { encoding: 'utf-8' }); | ||
| } catch (e: any) { | ||
| debug(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm removing this debug. This only happens of the file exists but cannot be read, which seems super unliekly. The helper is called from only two places. If someone feels strongly about it, I can implement this in the call-sites.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this is used in our proxy support, I feel we need any bit of information while debugging strange behavior there. I don't mind dropping it from the user agent construction.
|
|
||
| const options: RequestOptions = { | ||
| agent: await new ProxyAgentProvider(this.ioHelper).create(this.options), | ||
| }; | ||
|
|
||
| const notices = await new Promise<Notice[]>((resolve, reject) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bit of a rejig here to allow sending a message after the promise resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could just have done a .then() at the end 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to change it, I don't mind either way. I've received feedback in the past that mixing promise styles is confusing.
| ): Promise<SuccessfulDeployStackResult | undefined> { | ||
| let hotswapProps = hotswapPropertyOverrides || new HotswapPropertyOverrides(); | ||
| return deployments.tryHotswapDeployment(this, asIoHelper(ioHost, 'deploy'), assetParams, currentCfnStack, stackArtifact, hotswapMode, hotswapProps); | ||
| return deployments.tryHotswapDeployment(this, asIoHelper(ioHost, 'deploy'), assetParams, currentCfnStack, stackArtifact, hotswapMode as any, hotswapProps); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was a type error before. tryHotswapDeployment only takes two of the 3 enum values and in the CLI code this is enforced. Tests also don't call the method with the third value.
| */ | ||
| @traceMemberMethods | ||
| export class SDK { | ||
| private static readonly accountCache = new AccountAccessKeyCache(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't need to be a singleton. The class is always reading/writing from a file anywhere and does not cache values. If we ever wanted to, we can make the cache a singleton but keep the class as an instance per SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could also be made a constructor argument. Same point as for the proxy agent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could also be made a constructor argument. Same point as for the proxy agent.
True. There is opportunity for refactoring. Right now I want to keep the changes to the minimum to get this in.
| public static requestHandlerBuilder(options: SdkHttpOptions = {}): NodeHttpHandlerOptions { | ||
| const agent = this.proxyAgent(options); | ||
| public async requestHandlerBuilder(options: SdkHttpOptions = {}): Promise<NodeHttpHandlerOptions> { | ||
| const agent = await new ProxyAgentProvider(this.ioHelper).create(options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are changing these things, it would be better to pass then agent as a constructor argument. Let the SDK Provider, which is the factory class, to also instantiate this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried, but it has a bunch of knock-on effects that I don't want to deal with right now.
| */ | ||
| @traceMemberMethods | ||
| export class SDK { | ||
| private static readonly accountCache = new AccountAccessKeyCache(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could also be made a constructor argument. Same point as for the proxy agent.
| } | ||
| return fs.readFileSync(filename, { encoding: 'utf-8' }); | ||
| } catch (e: any) { | ||
| debug(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this is used in our proxy support, I feel we need any bit of information while debugging strange behavior there. I don't mind dropping it from the user agent construction.
| * The default path used for the accounts access key cache | ||
| */ | ||
| public static get DEFAULT_PATH(): string { | ||
| // needs to be a getter because cdkCacheDir can be set via env variable and might change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...during tests?
(Trying to wrap my head around how an env var might change across the execution)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
during tests, but in toolkit-lib it could be at any point of the code execution.
a839899 to
a78e710
Compare
Updates
aws-authmodule to use modern messaging infrastructure.Testing
tests/test-non-commercial-region.shwhich was skipped.AccountAccessKeyCacheis still writtenBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license