-
Notifications
You must be signed in to change notification settings - Fork 9.9k
Evaluate list resources #37070
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
base: main
Are you sure you want to change the base?
Evaluate list resources #37070
Conversation
cf9cbde
to
43ba8dd
Compare
c6a67de
to
583b873
Compare
43ba8dd
to
afe811e
Compare
583b873
to
1eba6dd
Compare
afe811e
to
9e48802
Compare
9e48802
to
922d04c
Compare
3816305
to
9da5b55
Compare
2e75a38
to
4465326
Compare
f8b1551
to
593d752
Compare
24d0a55
to
439cb9e
Compare
Before: cty.DynamicVal, | ||
After: vals, | ||
BeforeIdentity: cty.DynamicVal, | ||
AfterIdentity: ids, |
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.
I'm not sure if we should be overloading this for list
or not. In fact I wonder if these should be combined into the list object that also contains the resource objects, that way they are directly paired and we can choose to expose those via configuration for import
.
Change: plans.Change{ | ||
Action: plans.Read, | ||
Before: cty.DynamicVal, | ||
After: vals, |
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.
If we start evaluating this into normal configuration, I think we're going to want the vals
to correspond to the same type as the list
block object, rather than a tuple
. That object could also give us a place to store the identities, which so have not been exposed in the configuration at all. This is why I mentioned that we need to complete the design of the configuration first, since the object type we use will follow that type.
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.
I think we're going to want the vals to correspond to the same type as the list block object
I think what is being said here is to move the list
block object construction from
terraform/internal/terraform/evaluate.go
Lines 925 to 944 in 9980cdf
func (d *evaluationStateData) wrapListResourceValues(ident, obj cty.Value) cty.Value { | |
ret := make([]cty.Value, 0) | |
objIter := obj.ElementIterator() | |
identIter := ident.ElementIterator() | |
for objIter.Next() && identIter.Next() { | |
objKey, objVal := objIter.Element() | |
identKey, identVal := identIter.Element() | |
if objKey.Equals(identKey).False() { | |
panic(fmt.Sprintf("List resource has mismatched keys %s and %s", objKey, identKey)) | |
} | |
ret = append(ret, cty.ObjectVal(map[string]cty.Value{ | |
"state": objVal, | |
"identity": identVal, | |
})) | |
} | |
return cty.ObjectVal(map[string]cty.Value{ | |
"data": cty.TupleVal(ret), | |
}) | |
} |
and do that here instead. Based on my understanding, either way would be fine. Is there any reason why the plan changes requires the exact type of the list result?
Use the result of the ListResource RPC to build the state of the resource being listed. Then the tests are converted to table-driven tests, and they examine the resource state
518bd67
to
4ff576a
Compare
This PR implements the evaluation of list resources, then collects the results and stores them in the plan changes. It also
walkQuery
operation and integrated list resource execution into the standardwalkPlan
operation, but still being filtered out for now unless in query plan mode.Target Release
1.13.x
Rollback Plan
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
CHANGELOG entry