-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
NodeJS transforms #15532
NodeJS transforms #15532
Conversation
Changelog[uncommitted] (2024-03-06)Features
|
de9102d
to
d526b6f
Compare
sdk/nodejs/cmd/run/run.ts
Outdated
@@ -487,7 +487,8 @@ ${defaultMessage}`, | |||
}; | |||
|
|||
// Construct a `Stack` resource to represent the outputs of the program. | |||
const stackOutputs = stack.runInPulumiStack(runProgram); | |||
const stackOutputs = await stack.runInPulumiStack(runProgram); | |||
await settings.disconnect() |
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.
We need to disconnect here so that the callback server can be shutdown, otherwise it leaves the nodejs event loop forever running and we never hit process.on("exit", settings.disconnectSync);
sdk/nodejs/resource.ts
Outdated
* of the original call to the `Resource` constructor. If the transform returns undefined, | ||
* this indicates that the resource will not be transformed. | ||
*/ | ||
export type ResourceTransform = (args: ResourceTransformArgs) => Promise<ResourceTransformResult | undefined>; |
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.
Made this a promise because it's running async anyway so if people want to do async work inside transforms they can easily do so now.
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.
But this is now one more thing we're going to have to note in the migration guide -- that you basically have to use an async function now or return a promise.
Should we make it not return Promise or make it optionally return promise?
55edde6
to
0fa1875
Compare
...9--sdk-nodejs--add-experimental-support-to-the-nodejs-sdk-for-the-new-transforms-system.yaml
Show resolved
Hide resolved
response.setProperties(gstruct.Struct.fromJavaScript(sprops)); | ||
|
||
// Copy the options over. | ||
if (result.opts !== undefined) { |
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 seems a bit worrying. I don't know a lot of typescript, but having to copy every option here manually seems quite brittle for the future, in case we ever add any resource 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.
Indeed but it's changing from one domain to another, we have to do this manually :(
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 do worry about this also. When adding a new resource option there's a bunch of places that need to be kept up-to-date, this now being one of them. Wondering if there's a way to make that more obvious. Perhaps a comment on the ResourceOptions at a minimum?
1455c54
to
dbb8950
Compare
7405297
to
e364ce2
Compare
sdk/nodejs/resource.ts
Outdated
* of the original call to the `Resource` constructor. If the transform returns undefined, | ||
* this indicates that the resource will not be transformed. | ||
*/ | ||
export type ResourceTransform = (args: ResourceTransformArgs) => Promise<ResourceTransformResult | undefined>; |
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.
But this is now one more thing we're going to have to note in the migration guide -- that you basically have to use an async function now or return a promise.
Should we make it not return Promise or make it optionally return promise?
response.setProperties(gstruct.Struct.fromJavaScript(sprops)); | ||
|
||
// Copy the options over. | ||
if (result.opts !== undefined) { |
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 do worry about this also. When adding a new resource option there's a bunch of places that need to be kept up-to-date, this now being one of them. Wondering if there's a way to make that more obvious. Perhaps a comment on the ResourceOptions at a minimum?
901ba55
to
24601e6
Compare
47ca169
to
7dceb54
Compare
7dceb54
to
65c11d3
Compare
Draft changelog: ### Features - [auto/{go,nodejs,python}] Add support for suppress progress and suppress outputs parameters in the Automation API [#15596](#15596) - [pkg] Make schema.NewPluginLoader respect PULUMI_DEBUG_PROVIDERS, which enables Pulumi YAML programs to work correctly with this feature [#15526](#15526) - [sdk/dotnet] Update dotnet language host to 3.60.0 [#15609](#15609) - [sdk/nodejs] Add experimental support to the NodeJS SDK for the new transforms system. [#15532](#15532) - [sdk/python] Add support for asynchronous invokes via a new `invoke_async` function [#15602](#15602) - [sdkgen/dotnet] Support for non-overlay components in codegen for pulumi-kubernetes provider [#15490](#15490) ### Bug Fixes - [cli] Fix a panic when the secrets provider is missing from the deployment snapshot [#15599](#15599) - [backend/service] Make decrypt/encrypt network calls retryable to help work around network hiccups [#15600](#15600) - [cli/new] Strip credentials and query strings from template URLs saved to project [#15586](#15586) - [engine] Fix an issue where snapshots could become invalid when doing a targeted up [#15476](#15476) - [pkg/testing] Make ProgramTest use a temporary PULUMI_HOME for each test [#15568](#15568) - [sdkgen/dotnet] Codegen fix for resources without constant input properties [#15488](#15488) - [sdk/nodejs] Properly capture node:crypto and global.crypto in node 19+ - [sdk/python] Fix determining plugins for old packages in the Python language host [#15576](#15576)
Description
This adds a new experimental feature to the NodeJS SDK to register remote transform functions. These are currently all prefixed 'X' to show they're experimental.
These transform functions will run even for resources created inside MLCs.
Checklist
make tidy
to update any new dependenciesmake lint
to verify my code passes the lint checkgofumpt
make changelog
and committed thechangelog/pending/<file>
documenting my change