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:
James Bardin 2019-09-19 09:53:23 -04:00
parent c49f976308
commit d4031918d1
3 changed files with 9 additions and 15 deletions

View File

@ -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
}

View File

@ -114,13 +114,11 @@ func TestParseRef(t *testing.T) {
{
`data.external.foo`,
&Reference{
Subject: ResourceInstance{
Resource: Resource{
Subject: Resource{
Mode: DataResourceMode,
Type: "external",
Name: "foo",
},
},
SourceRange: tfdiags.SourceRange{
Start: tfdiags.SourcePos{Line: 1, Column: 1, Byte: 0},
End: tfdiags.SourcePos{Line: 1, Column: 18, Byte: 17},
@ -592,13 +590,11 @@ func TestParseRef(t *testing.T) {
{
`boop_instance.foo`,
&Reference{
Subject: ResourceInstance{
Resource: Resource{
Subject: Resource{
Mode: ManagedResourceMode,
Type: "boop_instance",
Name: "foo",
},
},
SourceRange: tfdiags.SourceRange{
Start: tfdiags.SourcePos{Line: 1, Column: 1, Byte: 0},
End: tfdiags.SourcePos{Line: 1, Column: 18, Byte: 17},

View File

@ -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: