From d435cd5a1b53d132e3bb7bfd5b6f1fe3d0688b95 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Tue, 25 Jul 2023 13:48:00 -0700 Subject: [PATCH] stackconfig: Bring the source bundle with the config When we load stackconfig we don't immediately load any of the modules that component blocks refer to, so we need to bring the source bundle along with the configuration so that a downstream piece of code (the stack language runtime, currently) can load those from the same source bundle. --- internal/stacks/stackconfig/config.go | 9 ++++++++- internal/stacks/stackruntime/internal/stackeval/stack.go | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/stacks/stackconfig/config.go b/internal/stacks/stackconfig/config.go index 88e67d6361..b369e0c753 100644 --- a/internal/stacks/stackconfig/config.go +++ b/internal/stacks/stackconfig/config.go @@ -27,6 +27,12 @@ const maxEmbeddedStackNesting = 20 // so on for arbitrary levels of nesting. type Config struct { Root *ConfigNode + + // Sources is the source bundle that the configuration was loaded from. + // + // This is also the source bundle that any Terraform modules used by + // components should be loaded from. + Sources *sourcebundle.Bundle } // ConfigNode represents a node in a tree of stacks that are to be planned and @@ -66,7 +72,8 @@ func LoadConfigDir(sourceAddr sourceaddrs.FinalSource, sources *sourcebundle.Bun } ret := &Config{ - Root: rootNode, + Root: rootNode, + Sources: sources, } // Before we return we need to walk the tree and resolve all of the diff --git a/internal/stacks/stackruntime/internal/stackeval/stack.go b/internal/stacks/stackruntime/internal/stackeval/stack.go index d5cb196f1c..ce1dfac734 100644 --- a/internal/stacks/stackruntime/internal/stackeval/stack.go +++ b/internal/stacks/stackruntime/internal/stackeval/stack.go @@ -198,6 +198,7 @@ func (s *Stack) InputsType(ctx context.Context) (cty.Type, *typeexpr.Defaults) { atys[vAddr.Name] = cfg.TypeConstraint() if def := cfg.DefaultValue(ctx); def != cty.NilVal { defs.DefaultValues[vAddr.Name] = def + opts = append(opts, vAddr.Name) } if childDefs := cfg.NestedDefaults(); childDefs != nil { defs.Children[vAddr.Name] = childDefs