(content *hcl.BodyContent, blockLabels []blockLabel, ctx *hcl.EvalContext)
| 1575 | } |
| 1576 | |
| 1577 | func (s *TransformFuncSpec) decode(content *hcl.BodyContent, blockLabels []blockLabel, ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) { |
| 1578 | wrappedVal, diags := s.Wrapped.decode(content, blockLabels, ctx) |
| 1579 | if diags.HasErrors() { |
| 1580 | // We won't try to run our function in this case, because it'll probably |
| 1581 | // generate confusing additional errors that will distract from the |
| 1582 | // root cause. |
| 1583 | return cty.UnknownVal(s.impliedType().WithoutOptionalAttributesDeep()), diags |
| 1584 | } |
| 1585 | |
| 1586 | resultVal, err := s.Func.Call([]cty.Value{wrappedVal}) |
| 1587 | if err != nil { |
| 1588 | // This is not a good example of a diagnostic because it is reporting |
| 1589 | // a programming error in the calling application, rather than something |
| 1590 | // an end-user could act on. |
| 1591 | diags = append(diags, &hcl.Diagnostic{ |
| 1592 | Severity: hcl.DiagError, |
| 1593 | Summary: "Transform function failed", |
| 1594 | Detail: fmt.Sprintf("Decoder transform returned an error: %s", err), |
| 1595 | Subject: s.sourceRange(content, blockLabels).Ptr(), |
| 1596 | }) |
| 1597 | return cty.UnknownVal(s.impliedType().WithoutOptionalAttributesDeep()), diags |
| 1598 | } |
| 1599 | |
| 1600 | return resultVal, diags |
| 1601 | } |
| 1602 | |
| 1603 | func (s *TransformFuncSpec) impliedType() cty.Type { |
| 1604 | wrappedTy := s.Wrapped.impliedType() |
nothing calls this directly
no test coverage detected