Skip to content

chore: refactor ingestion lambda to use loader function from @jsii/spec #920

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 8 commits into from
Jul 20, 2022

Conversation

kaizencc
Copy link
Contributor

@kaizencc kaizencc commented Jun 30, 2022

Uses loadAssemblyFromBuffer, a new function available in jsii v1.62.0.

This refactor does not break any current tests


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

@kaizencc kaizencc marked this pull request as draft June 30, 2022 19:58
parsedAssembly = validateAssembly(
JSON.parse(dotJsii.toString('utf-8'))
);
parsedAssembly = loadAssemblyFromBuffer(dotJsii, compDotJsii);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the magic jsii function in question. I find this the most reasonable thing to do because we already have a mechanism in place (extractObjects) that can parse the .jsii and possible .jsii.gz file. Writing loadAssemblyFromTarball will result in a redundant copy of a lot of extractObjects' logic. Best of all, this way, we only parse the tarball once.

mergify bot pushed a commit to aws/jsii that referenced this pull request Jul 6, 2022
Usage is demonstrated here: cdklabs/construct-hub#920

Two implementations were considered to fit the use case in construct hub, `loadAssemblyFromBuffer` and `loadAssemblyFromTarball`. I went with loading from a buffer because it allows us to utilize prior art in construct hub for parsing tarballs, does not need an added dependency on `tar`, and causes minimal impact when refactoring the ingestion lambda to use this function.

Also includes a small refactoring of the test suite. 

---

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

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
@kaizencc kaizencc requested a review from RomainMuller July 14, 2022 21:52
kaizencc and others added 2 commits July 18, 2022 18:35
Signed-off-by: github-actions <[email protected]>
@kaizencc kaizencc marked this pull request as ready for review July 18, 2022 22:43
@mergify mergify bot merged commit 6bdc349 into main Jul 20, 2022
@mergify mergify bot deleted the conroy/utils branch July 20, 2022 15:04
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.

2 participants