pulumi/pkg/codegen/pcl
Zaid Ajaj b96f19b2fa
[program-gen/pcl] Fixes type-annotating nested resource properties when these have quoted keys (#15001)
# Description

When binding resource properties and annotating these with types from
their schemas, we seem to skip this annotation process when resource
properties and their nested objects use _quoted_ keys `{ "key" = <value>
}` rather than using _literal_ keys `{ key = <value> }`.

This results in issues such as
https://github.com/pulumi/kube2pulumi/issues/60 where a csharp property
name override was not correctly applied because
1) kube2pulumi generated properties for resources that are quoted (this
should be fine)
2) binding the resource properties skipped annotating the nested object
with its corresponding schema type
3) program-gen in dotnet didn't have access to the schema type of the
nested object to correctly apply the property override

This PR fixes this issue by extending PCL resource binding to also check
for properties which have quoted keys.

Fixes https://github.com/pulumi/kube2pulumi/issues/60 and potentially
other issues that arise from converters generating PCL with quoted keys.

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
  - [ ] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [x] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2023-12-27 12:42:52 +00:00
..
binder.go Clean up uses of .Error() (#14965) 2023-12-20 15:54:06 +00:00
binder_component.go Propagate SkipRangeTypechecking option down to program components 2023-07-14 19:00:38 +02:00
binder_nodes.go Allow null literal as a default value for config variables 2023-05-04 00:38:38 +02:00
binder_resource.go [program-gen/pcl] Fixes type-annotating nested resource properties when these have quoted keys (#15001) 2023-12-27 12:42:52 +00:00
binder_resource_test.go pcl/options: Support retainOnDelete 2023-03-03 10:29:59 -08:00
binder_schema.go Allow binding unsupported range and collection types in non-strict mode for pulumi convert 2023-07-12 19:13:57 +02:00
binder_schema_test.go all: Assert => Assertf 2023-03-03 14:37:43 -08:00
binder_test.go Allow binding unsupported range and collection types in non-strict mode for pulumi convert 2023-07-12 19:13:57 +02:00
component.go lint 2023-07-27 16:32:06 +02:00
config.go Implement description as comments or docstring for config variables in program-gen 2023-03-21 15:01:16 +01:00
diagnostics.go Extend SkipResourceTypechecking to allow generating unknown resources 2023-06-14 19:02:56 +02:00
functions.go lint 2023-07-13 01:08:42 +02:00
functions_test.go Replace some more uses of assert.Contains(err.Error()) with assert.ErrorContains (#14863) 2023-12-15 17:45:32 +00:00
intrinsics.go all: Assert => Assertf 2023-03-03 14:37:43 -08:00
invoke.go Update golangci-lint (#14624) 2023-11-21 15:16:13 +00:00
local.go Do not panic when the type of PCL local variable isn't known 2023-04-13 20:05:16 +02:00
output.go codegen: preserve externally visible names of a resources and outputs (#9464) 2022-04-25 15:07:25 -07:00
program.go Use slice.Prealloc instead of make([]T, 0, ...) 2023-06-29 11:27:50 +01:00
resource.go Implement lenient traversal for resources 2023-06-20 13:50:18 +02:00
rewrite_apply.go Support range expressions that are of type output 2023-04-26 20:00:32 +02:00
rewrite_apply_test.go Allow binding unsupported range and collection types in non-strict mode for pulumi convert 2023-07-12 19:13:57 +02:00
rewrite_convert.go Fixes panic when trying to convert a null literal to a string value 2023-06-09 12:52:10 +02:00
rewrite_convert_test.go Fixes panic when generating go from pulumi yaml (#10047) 2022-07-07 13:15:47 -07:00
rewrite_properties.go all: Assert => Assertf 2023-03-03 14:37:43 -08:00
type.go [codegen] simplify opaque types to string newtype (#9770) 2022-06-13 11:13:03 -07:00
utilities.go lint 2023-07-28 20:47:36 +02:00
utilities_test.go lint 2023-05-25 22:16:00 +02:00