pulumi/pkg
Zaid Ajaj 0d458a47df
[program-gen] Fix PCL bind error "cannot iterate over a value of type number" (#17569)
### Description

Often when converting terraform modules such as tf VPC module, the range
expression of resources is a conditional expression of the form `if
should_create_resource ? N : 0`.

These expressions resolve their type to one of `int`, `bool`,
`Output[int]` or `Output[bool]`. Any other type we assume we are dealing
with a collection that we are trying to iterate over. However if the
conditional expression resolves to `optional(int)` then we think it is a
collection, try to get it's key-value pair types and error with "cannot
iterate over a value of type number"

This PR fixes this problem by unwrapping `int` from `optional(int)` when
encountered in these range expressions.

I was able to isolate a subset of the converted PCL from terraform VPC
module where this problem occurs and created a unit test from it.

Interesting note is that this only occurs in _non-strict_ mode 🤔 in
strict mode, the expression type from `range` is not optional. I've not
been able to find out why that is the case yet.
2024-10-17 20:55:38 +00:00
..
asset Move some asset code to pkg (#15162) 2024-01-17 11:30:37 +00:00
authhelpers Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
backend make sure the token source test is not flaky (#17545) 2024-10-14 08:44:41 +00:00
cmd/pulumi Remove `pulumi package add` error for YAML (#17560) 2024-10-15 18:45:06 +00:00
codegen [program-gen] Fix PCL bind error "cannot iterate over a value of type number" (#17569) 2024-10-17 20:55:38 +00:00
display Move sdk/go/common/display to /pkg/display (#13954) 2023-09-18 11:01:28 +00:00
engine Enable some more linting rules (#17456) 2024-10-03 17:37:13 +00:00
graph Support topologically sorting snapshots (#17403) 2024-10-01 08:45:35 +00:00
importer [cli/import] Fix undefined variable errors in code generation when imported resources use a parent or provider (#16786) 2024-07-25 13:53:44 +00:00
operations Move resource.URN to urn.URN (#15689) 2024-03-14 15:28:32 +00:00
resource Remove unused deployment option (#17559) 2024-10-16 08:54:32 +00:00
secrets Enable some more linting rules (#17456) 2024-10-03 17:37:13 +00:00
testing/integration Enable some more linting rules (#17456) 2024-10-03 17:37:13 +00:00
util Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
version duplicate version to ensure linking is properly handled 2020-03-19 12:49:34 -07:00
workspace Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
README.md export codegen tests for internal use (#8928) 2022-02-07 12:10:04 +01:00
go.mod Update yaml to 1.11.1 (#17540) 2024-10-10 19:42:11 +00:00
go.sum Update yaml to 1.11.1 (#17540) 2024-10-10 19:42:11 +00:00

README.md

pulumi/pkg

While pulumi/sdk maintains strict backwards compatibility guarantees, code under pkg/ is handled more informally: while breaking changes are still discouraged they may happen when they make sense.