-
Notifications
You must be signed in to change notification settings - Fork 27
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
Conversation
parsedAssembly = validateAssembly( | ||
JSON.parse(dotJsii.toString('utf-8')) | ||
); | ||
parsedAssembly = loadAssemblyFromBuffer(dotJsii, compDotJsii); |
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 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.
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
Signed-off-by: github-actions <[email protected]>
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