addrs: Rename AbsModuleCallOutput to ModuleCallInstanceOutput
The previous name didn't fit with the naming scheme for addrs types: The "Abs" prefix typically means that it's an addrs.ModuleInstance combined with whatever type name appears after "Abs", but this is instead a ModuleCallOutput combined with an InstanceKey, albeit structured the other way around for convenience, and so the expected name for this would be the suffix "Instance". We don't have an "Abs" type corresponding with this one because it would represent no additional information than AbsOutputValue.
This commit is contained in:
parent
2fdf898680
commit
ab350289ab
|
@ -72,9 +72,9 @@ func (m ModuleCallOutput) String() string {
|
|||
return fmt.Sprintf("%s.%s", m.Call.String(), m.Name)
|
||||
}
|
||||
|
||||
// AbsModuleCallOutput is the address of a particular named output produced by
|
||||
// ModuleCallInstanceOutput is the address of a particular named output produced by
|
||||
// an instance of a module call.
|
||||
type AbsModuleCallOutput struct {
|
||||
type ModuleCallInstanceOutput struct {
|
||||
referenceable
|
||||
Call ModuleCallInstance
|
||||
Name string
|
||||
|
@ -82,21 +82,21 @@ type AbsModuleCallOutput struct {
|
|||
|
||||
// ModuleCallOutput returns the referenceable ModuleCallOutput for this
|
||||
// particular instance.
|
||||
func (co AbsModuleCallOutput) ModuleCallOutput() ModuleCallOutput {
|
||||
func (co ModuleCallInstanceOutput) ModuleCallOutput() ModuleCallOutput {
|
||||
return ModuleCallOutput{
|
||||
Call: co.Call.Call,
|
||||
Name: co.Name,
|
||||
}
|
||||
}
|
||||
|
||||
func (co AbsModuleCallOutput) String() string {
|
||||
func (co ModuleCallInstanceOutput) String() string {
|
||||
return fmt.Sprintf("%s.%s", co.Call.String(), co.Name)
|
||||
}
|
||||
|
||||
// AbsOutputValue returns the absolute output value address that corresponds
|
||||
// to the receving module call output address, once resolved in the given
|
||||
// calling module.
|
||||
func (co AbsModuleCallOutput) AbsOutputValue(caller ModuleInstance) AbsOutputValue {
|
||||
func (co ModuleCallInstanceOutput) AbsOutputValue(caller ModuleInstance) AbsOutputValue {
|
||||
moduleAddr := co.Call.ModuleInstance(caller)
|
||||
return moduleAddr.OutputValue(co.Name)
|
||||
}
|
||||
|
|
|
@ -66,13 +66,13 @@ func (v AbsOutputValue) Equal(o AbsOutputValue) bool {
|
|||
//
|
||||
// The root module does not have a call, and so this method cannot be used
|
||||
// with outputs in the root module, and will panic in that case.
|
||||
func (v AbsOutputValue) ModuleCallOutput() (ModuleInstance, AbsModuleCallOutput) {
|
||||
func (v AbsOutputValue) ModuleCallOutput() (ModuleInstance, ModuleCallInstanceOutput) {
|
||||
if v.Module.IsRoot() {
|
||||
panic("ReferenceFromCall used with root module output")
|
||||
}
|
||||
|
||||
caller, call := v.Module.CallInstance()
|
||||
return caller, AbsModuleCallOutput{
|
||||
return caller, ModuleCallInstanceOutput{
|
||||
Call: call,
|
||||
Name: v.OutputValue.Name,
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ func parseRef(traversal hcl.Traversal) (*Reference, tfdiags.Diagnostics) {
|
|||
if attrTrav, ok := remain[0].(hcl.TraverseAttr); ok {
|
||||
remain = remain[1:]
|
||||
return &Reference{
|
||||
Subject: AbsModuleCallOutput{
|
||||
Subject: ModuleCallInstanceOutput{
|
||||
Name: attrTrav.Name,
|
||||
Call: callInstance,
|
||||
},
|
||||
|
|
|
@ -294,7 +294,7 @@ func TestParseRef(t *testing.T) {
|
|||
{
|
||||
`module.foo.bar`,
|
||||
&Reference{
|
||||
Subject: AbsModuleCallOutput{
|
||||
Subject: ModuleCallInstanceOutput{
|
||||
Call: ModuleCallInstance{
|
||||
Call: ModuleCall{
|
||||
Name: "foo",
|
||||
|
@ -312,7 +312,7 @@ func TestParseRef(t *testing.T) {
|
|||
{
|
||||
`module.foo.bar.baz`,
|
||||
&Reference{
|
||||
Subject: AbsModuleCallOutput{
|
||||
Subject: ModuleCallInstanceOutput{
|
||||
Call: ModuleCallInstance{
|
||||
Call: ModuleCall{
|
||||
Name: "foo",
|
||||
|
@ -355,7 +355,7 @@ func TestParseRef(t *testing.T) {
|
|||
{
|
||||
`module.foo["baz"].bar`,
|
||||
&Reference{
|
||||
Subject: AbsModuleCallOutput{
|
||||
Subject: ModuleCallInstanceOutput{
|
||||
Call: ModuleCallInstance{
|
||||
Call: ModuleCall{
|
||||
Name: "foo",
|
||||
|
@ -374,7 +374,7 @@ func TestParseRef(t *testing.T) {
|
|||
{
|
||||
`module.foo["baz"].bar.boop`,
|
||||
&Reference{
|
||||
Subject: AbsModuleCallOutput{
|
||||
Subject: ModuleCallInstanceOutput{
|
||||
Call: ModuleCallInstance{
|
||||
Call: ModuleCall{
|
||||
Name: "foo",
|
||||
|
|
|
@ -68,9 +68,9 @@ func marshalExpression(ex hcl.Expression) expression {
|
|||
// Include the resource, without the key
|
||||
varString = append(varString, ref.Subject.(addrs.ResourceInstance).Resource.String())
|
||||
}
|
||||
case addrs.AbsModuleCallOutput:
|
||||
case addrs.ModuleCallInstanceOutput:
|
||||
// Include the module name, without the output name
|
||||
varString = append(varString, ref.Subject.(addrs.AbsModuleCallOutput).Call.String())
|
||||
varString = append(varString, ref.Subject.(addrs.ModuleCallInstanceOutput).Call.String())
|
||||
}
|
||||
}
|
||||
ret.References = varString
|
||||
|
|
|
@ -47,7 +47,7 @@ func (d *dataForTests) GetModule(addr addrs.ModuleCall, rng tfdiags.SourceRange)
|
|||
return d.Modules[addr.String()], nil
|
||||
}
|
||||
|
||||
func (d *dataForTests) GetModuleInstanceOutput(addr addrs.AbsModuleCallOutput, rng tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) {
|
||||
func (d *dataForTests) GetModuleInstanceOutput(addr addrs.ModuleCallInstanceOutput, rng tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) {
|
||||
// This will panic if the module object does not have the requested attribute
|
||||
obj := d.Modules[addr.Call.String()]
|
||||
return obj.GetAttr(addr.Name), nil
|
||||
|
|
|
@ -341,7 +341,7 @@ func (s *Scope) evalContext(refs []*addrs.Reference, selfAddr addrs.Referenceabl
|
|||
rawSubj = addr.ContainingResource()
|
||||
case addrs.ModuleCallInstance:
|
||||
rawSubj = addr.Call
|
||||
case addrs.AbsModuleCallOutput:
|
||||
case addrs.ModuleCallInstanceOutput:
|
||||
rawSubj = addr.Call.Call
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ func (d *evaluationStateData) staticValidateReference(ref *addrs.Reference, self
|
|||
return d.staticValidateModuleCallReference(modCfg, addr, ref.Remaining, ref.SourceRange)
|
||||
case addrs.ModuleCallInstance:
|
||||
return d.staticValidateModuleCallReference(modCfg, addr.Call, ref.Remaining, ref.SourceRange)
|
||||
case addrs.AbsModuleCallOutput:
|
||||
case addrs.ModuleCallInstanceOutput:
|
||||
// This one is a funny one because we will take the output name referenced
|
||||
// and use it to fake up a "remaining" that would make sense for the
|
||||
// module call itself, rather than for the specific output, and then
|
||||
|
|
|
@ -296,7 +296,7 @@ func (m ReferenceMap) References(v dag.Vertex) []dag.Vertex {
|
|||
subject = ri.ContainingResource()
|
||||
case addrs.ResourceInstancePhase:
|
||||
subject = ri.ContainingResource()
|
||||
case addrs.AbsModuleCallOutput:
|
||||
case addrs.ModuleCallInstanceOutput:
|
||||
subject = ri.ModuleCallOutput()
|
||||
case addrs.ModuleCallInstance:
|
||||
subject = ri.Call
|
||||
|
|
Loading…
Reference in New Issue