Skip to content

chore(codegen,config-resolver): refactor how endpoint is resolved for non-AWS client #2287

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

Merged
merged 2 commits into from
Apr 23, 2021

Conversation

gosar
Copy link
Contributor

@gosar gosar commented Apr 21, 2021

Description

This is a refactoring of my earlier attempt at getting a non-AWS client working wrt endpoint resolution. This addresses the concern in #2279 (comment) by separating out the logic used by AWS client v/s non-AWS client. Also makes endpoint required for non-AWS client, addressing adamthom-amzn#1 (comment).

This approach adds some duplication. But seems to fit within the current plugin model in the codegen. Trying to use the same EndpointsConfig.ts but different methods/types would not fit easily into the ServiceGenerator logic. I thought it is better to have some minimal duplication in config-resolver than bigger restructing in codegen.

Testing

I generated the client used in our smithy-typescript-ssdk-demo package and it worked with these changes.

Questions:

  • Let me know if chore(codegen,config-resolver): refactor how endpoint is resolved for non-AWS client matches the expectation of git commit titles for when this is squashed and merged. Or is chore: refactor how endpoint is resolved for non-AWS client better?
  • EndpointsConfig and AwsEndpointsConfig may be better than NonAwsEndpointsConfig and EndpointsConfig. Is it fine to rename these? Or other suggestions on names. (edit): Using EndpointsConfig (for AWS) and CustomEndpointsConfig (for non-AWS) now. Let me know if other suggestions.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@gosar gosar force-pushed the endpoint-resolve branch from fbd089e to 74a4e31 Compare April 21, 2021 23:29
@gosar gosar changed the title chore(codegen,config-resolver) chore(codegen,config-resolver): refactor how endpoint is resolved for non-AWS client Apr 21, 2021
@gosar gosar force-pushed the endpoint-resolve branch from 74a4e31 to 3de446e Compare April 21, 2021 23:56
@gosar gosar requested a review from adamthom-amzn April 21, 2021 23:57
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • CodeBuild project: sdk-staging-test
  • Commit ID: 3de446e
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

gosar added 2 commits April 22, 2021 14:49
This reverts an earlier change to EndpointsConfig.ts and instead
provides the new functionality in separate
CustomEndpointsConfig.ts. This will be used as a separate plugin for
endpoint resolution in non AWS clients.
This depends on newly added CustomEndpointsConfig in
@aws-sdk/config-resolver package.
@gosar gosar force-pushed the endpoint-resolve branch from 3de446e to 9b040c6 Compare April 22, 2021 21:50
@gosar gosar requested a review from JordonPhillips April 22, 2021 21:52
@codecov-commenter
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (ssdk@092d239). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             ssdk    #2287   +/-   ##
=======================================
  Coverage        ?   61.83%           
=======================================
  Files           ?      454           
  Lines           ?    23291           
  Branches        ?     5520           
=======================================
  Hits            ?    14403           
  Misses          ?     8888           
  Partials        ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 092d239...9b040c6. Read the comment docs.

@gosar gosar merged commit e6f3919 into aws:ssdk Apr 23, 2021
JordonPhillips pushed a commit to JordonPhillips/aws-sdk-js-v3 that referenced this pull request Apr 26, 2021
… non-AWS client (aws#2287)

* chore(config-resolver): refactor EndpointsConfig for non AWS services

This reverts an earlier change to EndpointsConfig.ts and instead
provides the new functionality in separate
CustomEndpointsConfig.ts. This will be used as a separate plugin for
endpoint resolution in non AWS clients.

* feat(codegen): Use separate CustomEndpointsConfig for non-AWS clients

This depends on newly added CustomEndpointsConfig in
@aws-sdk/config-resolver package.
JordonPhillips added a commit that referenced this pull request Apr 29, 2021
* chore: serialize rest json error code header (#2166)

* chore: short-circuit ssdk-incompatible integrations (#2167)

* chore: disable idempotency autofill import when not generating a client (#2181)

* Support generating non-AWS client (#2222)

* feat(config-resolver): make region optional for non-AWS client

* feat(codegen): skip integrations that are not relevant for non-AWS services

This is an initial version to get a working version of generated code
that compiles without manual edits in smithy-typescript-ssdk-demo. I
expect to make updates to this logic.

* chore(codegen): address code comments

The minor ones from adamthom-amzn#1

* fix(codegen): use SigV4Trait check instead of ServiceTrait

AddAwsRuntimeConfigTest is checking for some behaviors from
AddAwsAuthPlugin too, which was failing with missing aws.auth#sigv4
trait after my change. Added the trait for now to the test, but unit
tests will need to be added/refactored for all these changes.

* chore(codegen): move isAwsService check to utils class

* chore(codegen): code style formatting

* chore(codegen): check SigV4 trait for including region

* chore(codegen,config-resolver): refactor how endpoint is resolved for non-AWS client (#2287)

* chore(config-resolver): refactor EndpointsConfig for non AWS services

This reverts an earlier change to EndpointsConfig.ts and instead
provides the new functionality in separate
CustomEndpointsConfig.ts. This will be used as a separate plugin for
endpoint resolution in non AWS clients.

* feat(codegen): Use separate CustomEndpointsConfig for non-AWS clients

This depends on newly added CustomEndpointsConfig in
@aws-sdk/config-resolver package.

* test(config-resolver): add test for CustomEndpointsConfig (#2305)

Co-authored-by: Adam Thomas <[email protected]>
Co-authored-by: Jaykumar Gosar <[email protected]>
@github-actions
Copy link

github-actions bot commented May 8, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants