MCPcopy
hub / github.com/hashicorp/hcl / decode

Method decode

hcldec/spec.go:1521–1537  ·  view source on GitHub ↗
(content *hcl.BodyContent, blockLabels []blockLabel, ctx *hcl.EvalContext)

Source from the content-addressed store, hash-verified

1519}
1520
1521func (s *TransformExprSpec) decode(content *hcl.BodyContent, blockLabels []blockLabel, ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) {
1522 wrappedVal, diags := s.Wrapped.decode(content, blockLabels, ctx)
1523 if diags.HasErrors() {
1524 // We won't try to run our function in this case, because it'll probably
1525 // generate confusing additional errors that will distract from the
1526 // root cause.
1527 return cty.UnknownVal(s.impliedType().WithoutOptionalAttributesDeep()), diags
1528 }
1529
1530 chiCtx := s.TransformCtx.NewChild()
1531 chiCtx.Variables = map[string]cty.Value{
1532 s.VarName: wrappedVal,
1533 }
1534 resultVal, resultDiags := s.Expr.Value(chiCtx)
1535 diags = append(diags, resultDiags...)
1536 return resultVal, diags
1537}
1538
1539func (s *TransformExprSpec) impliedType() cty.Type {
1540 wrappedTy := s.Wrapped.impliedType()

Callers

nothing calls this directly

Calls 5

impliedTypeMethod · 0.95
HasErrorsMethod · 0.80
NewChildMethod · 0.80
decodeMethod · 0.65
ValueMethod · 0.65

Tested by

no test coverage detected