MCPcopy
hub / github.com/opentofu/opentofu / DecodeBlock

Method DecodeBlock

internal/configs/static_evaluator.go:129–147  ·  view source on GitHub ↗
(ctx context.Context, body hcl.Body, spec hcldec.Spec, ident StaticIdentifier)

Source from the content-addressed store, hash-verified

127}
128
129func (s StaticEvaluator) DecodeBlock(ctx context.Context, body hcl.Body, spec hcldec.Spec, ident StaticIdentifier) (cty.Value, hcl.Diagnostics) {
130 var diags hcl.Diagnostics
131
132 refs, refsDiags := lang.References(addrs.ParseRef, hcldec.Variables(body, spec))
133 diags = append(diags, refsDiags.ToHCL()...)
134 if diags.HasErrors() {
135 return cty.DynamicVal, diags
136 }
137
138 hclCtx, ctxDiags := s.scope(ident).EvalContext(ctx, refs)
139 diags = append(diags, ctxDiags.ToHCL()...)
140 if diags.HasErrors() {
141 return cty.DynamicVal, diags
142 }
143
144 val, valDiags := hcldec.Decode(body, spec, hclCtx)
145 diags = append(diags, valDiags...)
146 return val, diags
147}
148
149func (s StaticEvaluator) EvalContext(ctx context.Context, ident StaticIdentifier, refs []*addrs.Reference) (*hcl.EvalContext, hcl.Diagnostics) {
150 return s.EvalContextWithParent(ctx, nil, ident, refs)

Callers 1

DecodeMethod · 0.80

Calls 7

HasErrorsMethod · 0.95
scopeMethod · 0.95
ReferencesFunction · 0.92
EvalContextMethod · 0.65
VariablesMethod · 0.45
ToHCLMethod · 0.45
DecodeMethod · 0.45

Tested by

no test coverage detected