Skip to content
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

Fix smithy sdk no default client #564

Merged
merged 6 commits into from
Jan 10, 2022
Merged

Conversation

kggilmer
Copy link
Contributor

@kggilmer kggilmer commented Jan 8, 2022

Issue #

N/A

Description of changes

  • This is a precursor to KMP project generation in smithy-kotlin. As-is, any generated Smithy client SDK is invalid (does not compile) because the client interface codegens references to a concrete client type that is not generated because no protocol is available. This has impact in codegen tests where we have to write test code in a specific way in order for the smithy sdk to compile, and also impacts ongoing work to develop and test kmp projects. It is likely that we'll have some kind of protocol in the future in smithy-kotlin at which point we may wish to revert this change, however this is unlikely to happen soon and so I choose this approach so that codegen tests can be cleaned up and kmp work can be unblocked. Also we'll probably always want to retain the capability to generate a client sdk sans protocol.

Additional Testing

  • Verified that codegen'd smithy sdk compiles successfully
  • Verified that paginator codegen tests can use any name for concrete client implementation

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@kggilmer kggilmer requested a review from a team as a code owner January 8, 2022 00:04
@@ -72,7 +73,7 @@ class ServiceGenerator(private val ctx: RenderingContext<ServiceShape>) {
SectionServiceCompanionObject,
context = mapOf(SectionServiceCompanionObject.ServiceSymbol to serviceSymbol)
) {
renderCompanionObject()
renderCompanionObject(ctx.protocolGenerator != null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style

ctx is a property on the class, no real reason to thread through the parameter

withBlock("operator fun invoke(block: Config.Builder.() -> Unit = {}): ${serviceSymbol.name} {", "}") {
write("val config = Config.Builder().apply(block).build()")
write("return Default${serviceSymbol.name}(config)")
this.callIf(hasProtocolGenerator) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit/style does this need qualified here?

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@kggilmer kggilmer merged commit 2a2387a into main Jan 10, 2022
@kggilmer kggilmer deleted the fix-smithy-sdk-no-default-client branch January 10, 2022 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants