From dee62db2f09e2525dc8d7e773a979e0f9a5fdfe3 Mon Sep 17 00:00:00 2001 From: Daniel Banck Date: Wed, 11 Feb 2026 14:48:45 +0100 Subject: [PATCH] Add SourceExpr and VersionExpr to module calls --- internal/configs/module_call.go | 8 +++++++- internal/configs/module_merge.go | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/internal/configs/module_call.go b/internal/configs/module_call.go index ecc3be1821..9ace57ee81 100644 --- a/internal/configs/module_call.go +++ b/internal/configs/module_call.go @@ -23,10 +23,12 @@ type ModuleCall struct { SourceAddrRaw string SourceAddrRange hcl.Range SourceSet bool + SourceExpr hcl.Expression Config hcl.Body - Version VersionConstraint + Version VersionConstraint + VersionExpr hcl.Expression Count hcl.Expression ForEach hcl.Expression @@ -68,6 +70,8 @@ func decodeModuleBlock(block *hcl.Block, override bool) (*ModuleCall, hcl.Diagno haveVersionArg := false if attr, exists := content.Attributes["version"]; exists { + mc.VersionExpr = attr.Expr + var versionDiags hcl.Diagnostics mc.Version, versionDiags = decodeVersionConstraint(attr) diags = append(diags, versionDiags...) @@ -75,6 +79,8 @@ func decodeModuleBlock(block *hcl.Block, override bool) (*ModuleCall, hcl.Diagno } if attr, exists := content.Attributes["source"]; exists { + mc.SourceExpr = attr.Expr + mc.SourceSet = true mc.SourceAddrRange = attr.Expr.Range() valDiags := gohcl.DecodeExpression(attr.Expr, nil, &mc.SourceAddrRaw) diff --git a/internal/configs/module_merge.go b/internal/configs/module_merge.go index 47251b23c7..a6d272ee60 100644 --- a/internal/configs/module_merge.go +++ b/internal/configs/module_merge.go @@ -180,6 +180,9 @@ func (mc *ModuleCall) merge(omc *ModuleCall) hcl.Diagnostics { mc.SourceAddrRange = omc.SourceAddrRange mc.SourceSet = omc.SourceSet } + if omc.SourceExpr != nil { + mc.SourceExpr = omc.SourceExpr + } if omc.Count != nil { mc.Count = omc.Count @@ -192,6 +195,9 @@ func (mc *ModuleCall) merge(omc *ModuleCall) hcl.Diagnostics { if len(omc.Version.Required) != 0 { mc.Version = omc.Version } + if omc.VersionExpr != nil { + mc.VersionExpr = omc.VersionExpr + } mc.Config = MergeBodies(mc.Config, omc.Config)