mirror of https://github.com/pulumi/pulumi.git
2394f0de7a
In this PR we fix generating constructor syntax examples for Kubernetes. The problem initially was due to generating a PCL program with syntax errors for the kubernetes schema. The syntax error was happening because we emitted properties `$ref` and `$schema` which are not valid identifiers in PCL. Fixing this was simple enough, we only needed to quote these properties that start with dollar signs and we get a valid PCL program. Full PCL program for kubernetes: https://gist.github.com/Zaid-Ajaj/abe899430a0b5f99a428934dcac75d52 However, the valid PCL program wouldn't convert to Go with program-gen and it would hang without showing any errors or stack traces. I wrote a script to split the programs for each resource and convert each separately. This way I narrowed down the problem to this program: ``` resource "def" "kubernetes:apiextensions.k8s.io/v1:CustomResourceDefinition" { apiVersion = "string" kind = "string" spec = { versions = [{}] } } ``` Debugging this in Go program-gen didn't show an obvious error and it kept on hanging. However I noticed that we lowering expressions twice: once for the entirety of resource inputs when generating resources and again when generating the expressions separately. Lowering expressions has been the source of many bugs and it seems to trip up program-gen a lot and suspected something wrong was going on here, so I simplified it to lower the expressions once when we generate resource inputs. This fixed the hang issue as well as a few of our test programs (see diffs for test programs and tests schemas) Tested this against the full kubernetes schema and we can now generate the full Go program: https://gist.github.com/Zaid-Ajaj/3ac734536969a989edae92219968d51f > The second time we lower expressions not only is redundant but also can generate invalid code if the lowered expressions have temporary variables because program-gen would just emit these variables inside inline expressions like objects and lists which gives invalid Go code. Resolves part of #16463 |
||
---|---|---|
.. | ||
kubernetes-pod.go |