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
|
// of the resource, but we don't have enough context here to decide
|
||||||
// so we'll let the caller resolve that ambiguity.
|
// so we'll let the caller resolve that ambiguity.
|
||||||
return &Reference{
|
return &Reference{
|
||||||
Subject: resourceInstAddr,
|
Subject: resourceAddr,
|
||||||
SourceRange: tfdiags.SourceRangeFromHCL(rng),
|
SourceRange: tfdiags.SourceRangeFromHCL(rng),
|
||||||
}, diags
|
}, diags
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,13 +114,11 @@ func TestParseRef(t *testing.T) {
|
||||||
{
|
{
|
||||||
`data.external.foo`,
|
`data.external.foo`,
|
||||||
&Reference{
|
&Reference{
|
||||||
Subject: ResourceInstance{
|
Subject: Resource{
|
||||||
Resource: Resource{
|
|
||||||
Mode: DataResourceMode,
|
Mode: DataResourceMode,
|
||||||
Type: "external",
|
Type: "external",
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
},
|
},
|
||||||
},
|
|
||||||
SourceRange: tfdiags.SourceRange{
|
SourceRange: tfdiags.SourceRange{
|
||||||
Start: tfdiags.SourcePos{Line: 1, Column: 1, Byte: 0},
|
Start: tfdiags.SourcePos{Line: 1, Column: 1, Byte: 0},
|
||||||
End: tfdiags.SourcePos{Line: 1, Column: 18, Byte: 17},
|
End: tfdiags.SourcePos{Line: 1, Column: 18, Byte: 17},
|
||||||
|
@ -592,13 +590,11 @@ func TestParseRef(t *testing.T) {
|
||||||
{
|
{
|
||||||
`boop_instance.foo`,
|
`boop_instance.foo`,
|
||||||
&Reference{
|
&Reference{
|
||||||
Subject: ResourceInstance{
|
Subject: Resource{
|
||||||
Resource: Resource{
|
|
||||||
Mode: ManagedResourceMode,
|
Mode: ManagedResourceMode,
|
||||||
Type: "boop_instance",
|
Type: "boop_instance",
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
},
|
},
|
||||||
},
|
|
||||||
SourceRange: tfdiags.SourceRange{
|
SourceRange: tfdiags.SourceRange{
|
||||||
Start: tfdiags.SourcePos{Line: 1, Column: 1, Byte: 0},
|
Start: tfdiags.SourcePos{Line: 1, Column: 1, Byte: 0},
|
||||||
End: tfdiags.SourcePos{Line: 1, Column: 18, Byte: 17},
|
End: tfdiags.SourcePos{Line: 1, Column: 18, Byte: 17},
|
||||||
|
|
|
@ -261,8 +261,6 @@ func (s *Scope) evalContext(refs []*addrs.Reference, selfAddr addrs.Referenceabl
|
||||||
// in package addrs.
|
// in package addrs.
|
||||||
switch subj := rawSubj.(type) {
|
switch subj := rawSubj.(type) {
|
||||||
case addrs.Resource:
|
case addrs.Resource:
|
||||||
panic("RESOURCE REFERENCES DON'T HIT THIS")
|
|
||||||
|
|
||||||
var into map[string]map[string]cty.Value
|
var into map[string]map[string]cty.Value
|
||||||
switch subj.Mode {
|
switch subj.Mode {
|
||||||
case addrs.ManagedResourceMode:
|
case addrs.ManagedResourceMode:
|
||||||
|
|
Loading…
Reference in New Issue