-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
helper/schema: track map element counts #678
Conversation
This adds "field.#" values to the state/diff with the element count of a map. This fixes a major issue around not knowing when child elements are computed when doing variable access of a computed map. Example, if you have a schema like this: "foo": &Schema{ Type: TypeMap, Computed: true, } And you access it like this in a resource: ${type.name.foo.computed-field} Then Terraform will error that "field foo could not be found on resource type.name". By adding that "foo.#" is computed, Terraform core will pick up that it WILL exist, so its okay.
@mitchellh I think you missed a bit here. When I add this test:
It fails saying What triggered me to check this was PR #661, but I must admit I'm not a 100% sure this test matches the actual use case your trying to fix here... |
@svanharmelen Good test failure! I'm fixing it now. |
@svanharmelen Got your test to pass! |
Merging, I think we're good. :) |
helper/schema: track map element counts
Nice!! |
This change breaks providers that are using maps as elements of their configuration, eg. heroku application or heroku addon. Maybe it would make sense to have a special abstraction layer over those maps, so that they are accessed in one way and persisted the other? |
@kubek2k Can you describe how it breaks those? I think long term we do need a way to persist in a different format. |
for example those lines: same is here: BTW: do you have any idea why the author used TypeList of maps instead of map for configuration? |
@mitchellh zing zing ^^ |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
This adds "field.#" values to the state/diff with the element count of a
map. This fixes a major issue around not knowing when child elements are
computed when doing variable access of a computed map.
Example, if you have a schema like this:
And you access it like this in a resource:
Then Terraform will error that "field foo could not be found on resource
type.name". By adding that "foo.#" is computed, Terraform core will pick
up that it WILL exist, so its okay.
@svanharmelen Since you've been in helper/schema recently, I'd appreciate a review. Thanks!