-
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
[program-gen] Emit Output-returning JSON serialization methods without rewriting applies #15371
Conversation
Changelog[uncommitted] (2024-02-04)Features
|
@@ -374,3 +374,6 @@ const ( | |||
RandomSchema SchemaVersion = "4.11.2" | |||
EksSchema SchemaVersion = "0.37.1" | |||
) | |||
|
|||
// PulumiDotnetSDKVersion is the version of the Pulumi .NET SDK to use in program-gen tests | |||
const PulumiDotnetSDKVersion = "3.59.0" |
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.
Added this so that program-gen can install and test generated programs against a specific version of .NET Pulumi SDK. In this case, latest version that contains the Output.JsonSerialize
function. In case of pulumi convert
, it already emits 3.*
so latest is resolved there as well
g.genDictionaryOrTuple(w, expr.Args[0]) | ||
g.Fgen(w, ")") | ||
if model.ContainsOutputs(expr.Args[0].Type()) { | ||
g.Fgen(w, "Output.JsonSerialize(Output.Create(") |
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 Output.JsonSerialize(Output.Create(...))
instead of Output.JsonSerialize(...)
because the function only accepts Output<T>
. We could simplify that in a subsequent PR after we generalize Output.JsonSerialize
to accept any T
…plies for top-level function expression
45ba0a3
to
f585188
Compare
### Features - [cli/config] Adds an `--open` flag to `pulumi config` command which resolves the environment listed in the stack configuration. - [auto/go] Automation API support for `pulumi refresh --preview-only` [#15340](#15340) - [engine] Add support for remote transforms to the engine. - [pkg/testing] Add a InstallDevReleases option to ProgramTest, to install pulumi dev SDKs [#15387](#15387) - [programgen/{dotnet,nodejs,python}] Emit Output-returning JSON serialization methods without rewriting applies for top-level function expression [#15371](#15371) - [sdk/nodejs] Detect npm and yarn workspaces setups when installing dependencies [#15421](#15421) - [sdk/nodejs] Use pnpm as package manager if we find a pnpm-lock.yaml file [#15456](#15456) ### Bug Fixes - [docs] Fixes docs generator parent module computation [#15035](#15035) - [engine] Test and fix the engine filling in args dependencies to provider calls. [#15450](#15450) - [programgen] Fix infinite recursion when binding invoke signature into promises without accounting for recursive type references [#15463](#15463)
### Features - [cli/config] Adds an `--open` flag to `pulumi config` command which resolves the environment listed in the stack configuration. [#15469](#15469) - [auto/go] Automation API support for `pulumi refresh --preview-only` [#15340](#15340) - [engine] Add support for remote transforms to the engine. [#15290](#15290) - [pkg/testing] Add a InstallDevReleases option to ProgramTest, to install pulumi dev SDKs [#15387](#15387) - [programgen/{dotnet,nodejs,python}] Emit Output-returning JSON serialization methods without rewriting applies for top-level function expression [#15371](#15371) - [sdk/nodejs] Detect npm and yarn workspaces setups when installing dependencies [#15421](#15421) - [sdk/nodejs] Use pnpm as package manager if we find a pnpm-lock.yaml file [#15456](#15456) ### Bug Fixes - [docs] Fixes docs generator parent module computation [#15035](#15035) - [engine] Test and fix the engine filling in args dependencies to provider calls. [#15450](#15450) - [programgen] Fix infinite recursion when binding invoke signature into promises without accounting for recursive type references [#15463](#15463)
Description
A while ago we started implementing specialized JSON serialization methods for Pulumi programs which can accept nested outputs without having to rewrite and combine applies.
Output.SerializeJson
in .NETpulumi.jsonStringify
in nodejspulumi.Output.json_dumps
in PythonThis PR extends program-gen for TypeScript, C# and Python to start emitting these JSON serialization functions (when necessary). The PR special-cases the
toJSON
PCL function when rewriting applies so that nested outputs aren't rewritted.Example PCL program and generated results:
Generated TypeScript Before
Generated TypeScript After
Generated Python Before
Generated Python After
Generated C# Before
Generated C# After
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