Skip to content
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

reify the list values before validation #13046

Merged
merged 2 commits into from
Mar 24, 2017
Merged

reify the list values before validation #13046

merged 2 commits into from
Mar 24, 2017

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented Mar 24, 2017

If the list was marked as computed, all values will be raw config
values. Fetch the individual keys from the config to get any known
values before validating.

#12892

Copy link
Contributor

@mitchellh mitchellh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, quick question: what happens to the computed values? I can't remember but it looks like your test checks that none have the interpolation value, where does that value go?

I seem to recall we purposely send computed values into validate so that validate can know the EXISTENCE (won't error that you must set) but at the same time can check if it its computed. Want to verify if that's the case here?

@jbardin
Copy link
Member Author

jbardin commented Mar 24, 2017

Hmm, that map in the test fixture schema looks little wonky (it was just there for good measure, not actually part of the bug). I'll fix that up.

@jbardin
Copy link
Member Author

jbardin commented Mar 24, 2017

computed primitive values are skipped completely, so ValidateFunc should never have to deal with the raw interpolation strings or know about UnknownValue.

@mitchellh
Copy link
Contributor

@jbardin An issue we ran into early then was the exists/not-exists check. For example: if an entire list is computed, will helper/schema properly see that some value may exist there in the future (and therefore pass validation)?

@jbardin
Copy link
Member Author

jbardin commented Mar 24, 2017

@mitchellh, In this case the list is marked as computed (which is why we had all raw values), which would skip ValidateFunc for the list if it had one (I confirmed that). The individual elements are still validated independently.

If you're referring to Resource.ExistsFunc, that's called from a different code path

Interpolation strings for non-computed values in a list were being
passed to the schema's ValidateFunc.
If the list was marked as computed, all values will be raw config
values. Fetch the individual keys from the config to get any known
values before validating.
@mitchellh
Copy link
Contributor

That works great.

Yeah not ExistsFunc that is to check if a resource exists via state (so never computed values) I think.

@ghost
Copy link

ghost commented Apr 15, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants