-
Notifications
You must be signed in to change notification settings - Fork 44
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
Make sure no nil lists are passed to TF #1688
Conversation
pkg/tfbridge/schema.go
Outdated
// Iterate over the TF schema and add an empty list for each list type not in the results. | ||
tfs.Range(func(key string, value shim.Schema) bool { | ||
schema := tfs.Get(key) | ||
if schema.Type() == shim.TypeList && result[key] == nil { |
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.
Does terraform distinguish between nil
and missing?
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.
Great question but I doubt it given the way they use them: https://github.com/hashicorp/terraform-provider-aws/blob/3645bd03060df19f5cf29c132e26f7e40b56230f/internal/service/elbv2/listener.go#L425C1-L427C3
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.
In maps yes, in objects no, an object having an optional field F will have it nil if it's missing, there's no other way for it to have it missing.
After a discussion with @t0yv0 I dug a bit into the code related to He suggested this is likely related to
pulumi-terraform-bridge/pkg/tfbridge/provider.go Line 1000 in 096668c
which one call down calls pulumi-terraform-bridge/pkg/tfbridge/schema.go Line 1233 in e877705
Which then calls
which only iterates over the
At this point the This means that the code which is meant to fill the empty array in place of the pulumi-terraform-bridge/pkg/tfbridge/schema.go Lines 357 to 362 in e877705
This means the issue is either:
The second one seems more likely to me, happy to be corrected here. |
2 sounds exact to me. The transformation is schema-aware and should be walking object fields even if they're not present in the source PropertyMap but are present in the schema, so it can apply the unflattening treatment as necessary. |
I still need some tests for this. |
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.
Looks good to me. LGTM
This reverts commit 6241673.
Addresses pulumi/pulumi-aws#3427
We should make sure we send the upstream provider an empty array where MaxItemsOne properties are expected instead of a nil, since that is what TF does.