From 657f9502e46b508ff355951924f5652ce783af87 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Thu, 21 Nov 2019 18:41:38 -0800 Subject: [PATCH] addrs: ModuleInstance.Module This returns the address of the module that the module instance is an instance of. --- addrs/module_instance.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/addrs/module_instance.go b/addrs/module_instance.go index eff9d1374..b2b51717a 100644 --- a/addrs/module_instance.go +++ b/addrs/module_instance.go @@ -410,6 +410,19 @@ func (m ModuleInstance) TargetContains(other Targetable) bool { } } +// Module returns the address of the module that this instance is an instance +// of. +func (m ModuleInstance) Module() Module { + if len(m) == 0 { + return nil + } + ret := make(Module, len(m)) + for i, step := range m { + ret[i] = step.Name + } + return ret +} + func (m ModuleInstance) targetableSigil() { // ModuleInstance is targetable }