From abd1ea7523f22896ba94de718c3d5d9a93472e7b Mon Sep 17 00:00:00 2001 From: Christian Mesh Date: Wed, 22 Apr 2026 15:35:11 -0400 Subject: [PATCH] Forgot consts file Signed-off-by: Christian Mesh --- internal/configs/symlib/consts.go | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 internal/configs/symlib/consts.go diff --git a/internal/configs/symlib/consts.go b/internal/configs/symlib/consts.go new file mode 100644 index 0000000000..33b491bc83 --- /dev/null +++ b/internal/configs/symlib/consts.go @@ -0,0 +1,33 @@ +package symlib + +import ( + "github.com/hashicorp/hcl/v2" + "github.com/hashicorp/hcl/v2/hclsyntax" +) + +type Const struct { + Name string + Expr hcl.Expression + DeclRange hcl.Range +} + +func decodeConstBlock(block *hcl.Block) ([]*Const, hcl.Diagnostics) { + var consts []*Const + attrs, diags := block.Body.JustAttributes() + for name, attr := range attrs { + if !hclsyntax.ValidIdentifier(name) { + diags = append(diags, &hcl.Diagnostic{ + Severity: hcl.DiagError, + Summary: "Invalid const value name", + Detail: badIdentifierDetail, + Subject: &attr.NameRange, + }) + } + consts = append(consts, &Const{ + Name: name, + Expr: attr.Expr, + DeclRange: attr.Range, + }) + } + return consts, diags +}