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

Detect when provider and resource/module have identical for_each #2186

Merged
merged 12 commits into from
Dec 3, 2024
Prev Previous commit
Next Next commit
configs: use addrs.TraversalsEquivalent to compare traversals
We now have a function directly intended for comparing two traversals for
equivalence, so we no longer need to cheat and use comparison of the
string representations that were intended for use only in the UI.

Signed-off-by: Martin Atkins <[email protected]>
  • Loading branch information
apparentlymart committed Dec 3, 2024
commit 99cfa66b153aac7ec365d2cc3ee4e2d596bb42d5
4 changes: 2 additions & 2 deletions internal/configs/provider_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -896,15 +896,15 @@ func providerIterationIdentical(a, b hcl.Expression) bool {
switch as := a.(type) {
case *hclsyntax.ScopeTraversalExpr:
if bs, bok := b.(*hclsyntax.ScopeTraversalExpr); bok {
return addrs.TraversalStr(as.Traversal) == addrs.TraversalStr(bs.Traversal)
return addrs.TraversalsEquivalent(as.Traversal, bs.Traversal)
}
case *hclsyntax.LiteralValueExpr:
if bs, bok := b.(*hclsyntax.LiteralValueExpr); bok {
return as.Val.Equals(bs.Val).True()
}
case *hclsyntax.RelativeTraversalExpr:
if bs, bok := b.(*hclsyntax.RelativeTraversalExpr); bok {
return addrs.TraversalStr(as.Traversal) == addrs.TraversalStr(bs.Traversal) &&
return addrs.TraversalsEquivalent(as.Traversal, bs.Traversal) &&
providerIterationIdentical(as.Source, bs.Source)
}
case *hclsyntax.FunctionCallExpr:
Expand Down
Loading