From edc02f2a0671500932898e3595dc5c0fd1b914ee Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Wed, 19 Jul 2023 15:30:47 -0700 Subject: [PATCH] stackaddrs: ConfigComponentForAbsInstance This helper discards all of the instance keys from an AbsComponentInstance to find the corresponding ConfigComponent. --- internal/stacks/stackaddrs/component.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/stacks/stackaddrs/component.go b/internal/stacks/stackaddrs/component.go index a7cef2e6ee..582d702ad8 100644 --- a/internal/stacks/stackaddrs/component.go +++ b/internal/stacks/stackaddrs/component.go @@ -67,6 +67,16 @@ type ConfigComponentInstance = InStackConfig[ComponentInstance] // particular [StackInstance]. type AbsComponentInstance = InStackInstance[ComponentInstance] +func ConfigComponentForAbsInstance(instAddr AbsComponentInstance) ConfigComponent { + configInst := ConfigForAbs(instAddr) // a ConfigComponentInstance + return ConfigComponent{ + Stack: configInst.Stack, + Item: Component{ + Name: configInst.Item.Component.Name, + }, + } +} + func ParseAbsComponentInstance(traversal hcl.Traversal) (AbsComponentInstance, tfdiags.Diagnostics) { if traversal.IsRelative() { // This is always a caller bug: caller must only pass absolute