mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-25 08:21:07 -06:00
parse resource refs correctly
Now that we only evaluate whole resources, we can parse resource refs correct as the resource, rather than an unknown instance.
This commit is contained in:
parent
c49f976308
commit
d4031918d1
@ -290,7 +290,7 @@ func parseResourceRef(mode ResourceMode, startRange hcl.Range, traversal hcl.Tra
|
||||
// of the resource, but we don't have enough context here to decide
|
||||
// so we'll let the caller resolve that ambiguity.
|
||||
return &Reference{
|
||||
Subject: resourceInstAddr,
|
||||
Subject: resourceAddr,
|
||||
SourceRange: tfdiags.SourceRangeFromHCL(rng),
|
||||
}, diags
|
||||
}
|
||||
|
@ -114,12 +114,10 @@ func TestParseRef(t *testing.T) {
|
||||
{
|
||||
`data.external.foo`,
|
||||
&Reference{
|
||||
Subject: ResourceInstance{
|
||||
Resource: Resource{
|
||||
Mode: DataResourceMode,
|
||||
Type: "external",
|
||||
Name: "foo",
|
||||
},
|
||||
Subject: Resource{
|
||||
Mode: DataResourceMode,
|
||||
Type: "external",
|
||||
Name: "foo",
|
||||
},
|
||||
SourceRange: tfdiags.SourceRange{
|
||||
Start: tfdiags.SourcePos{Line: 1, Column: 1, Byte: 0},
|
||||
@ -592,12 +590,10 @@ func TestParseRef(t *testing.T) {
|
||||
{
|
||||
`boop_instance.foo`,
|
||||
&Reference{
|
||||
Subject: ResourceInstance{
|
||||
Resource: Resource{
|
||||
Mode: ManagedResourceMode,
|
||||
Type: "boop_instance",
|
||||
Name: "foo",
|
||||
},
|
||||
Subject: Resource{
|
||||
Mode: ManagedResourceMode,
|
||||
Type: "boop_instance",
|
||||
Name: "foo",
|
||||
},
|
||||
SourceRange: tfdiags.SourceRange{
|
||||
Start: tfdiags.SourcePos{Line: 1, Column: 1, Byte: 0},
|
||||
|
@ -261,8 +261,6 @@ func (s *Scope) evalContext(refs []*addrs.Reference, selfAddr addrs.Referenceabl
|
||||
// in package addrs.
|
||||
switch subj := rawSubj.(type) {
|
||||
case addrs.Resource:
|
||||
panic("RESOURCE REFERENCES DON'T HIT THIS")
|
||||
|
||||
var into map[string]map[string]cty.Value
|
||||
switch subj.Mode {
|
||||
case addrs.ManagedResourceMode:
|
||||
|
Loading…
Reference in New Issue
Block a user