MCPcopy
hub / github.com/opentofu/opentofu / GetLocalValue

Method GetLocalValue

internal/configs/static_scope.go:129–156  ·  view source on GitHub ↗
(ctx context.Context, ident addrs.LocalValue, rng tfdiags.SourceRange)

Source from the content-addressed store, hash-verified

127}
128
129func (s staticScopeData) GetLocalValue(ctx context.Context, ident addrs.LocalValue, rng tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) {
130 var diags tfdiags.Diagnostics
131
132 local, ok := s.eval.cfg.Locals[ident.Name]
133 if !ok {
134 return cty.DynamicVal, diags.Append(&hcl.Diagnostic{
135 Severity: hcl.DiagError,
136 Summary: "Undefined local",
137 Detail: fmt.Sprintf("Undefined local %s", ident.String()),
138 Subject: rng.ToHCL().Ptr(),
139 })
140 }
141
142 id := StaticIdentifier{
143 Module: s.eval.call.addr,
144 Subject: fmt.Sprintf("local.%s", local.Name),
145 DeclRange: local.DeclRange,
146 }
147
148 scope, scopeDiags := s.scope(id)
149 diags = diags.Append(scopeDiags)
150 if diags.HasErrors() {
151 return cty.DynamicVal, diags
152 }
153
154 val, valDiags := scope.EvalExpr(ctx, local.Expr, cty.DynamicPseudoType)
155 return val, s.enhanceDiagnostics(id, diags.Append(valDiags))
156}
157
158func (s staticScopeData) GetModule(context.Context, addrs.ModuleCall, tfdiags.SourceRange) (cty.Value, tfdiags.Diagnostics) {
159 panic("Not Available in Static Context")

Callers

nothing calls this directly

Calls 7

AppendMethod · 0.95
scopeMethod · 0.95
HasErrorsMethod · 0.95
enhanceDiagnosticsMethod · 0.95
EvalExprMethod · 0.80
StringMethod · 0.65
ToHCLMethod · 0.45

Tested by

no test coverage detected