evalStringExpr handles string-type expressions with interpolation.
(expression string, refs []Value)
| 63 | if err != nil { |
| 64 | return false, err |
| 65 | } |
| 66 | return v.AsBool(), nil |
| 67 | } |
| 68 | |
| 69 | // evalStringExpr handles string-type expressions with interpolation. |
| 70 | func evalStringExpr(expression string, refs []Value) (Value, error) { |
| 71 | if expression == "" && len(refs) == 0 { |
| 72 | return StringVal(""), nil |
| 73 | } |
| 74 | if len(refs) == 0 { |
| 75 | return StringVal(expression), nil |
| 76 | } |
| 77 | |
| 78 | expression, refs = applyCastsInString(expression, refs) |
| 79 | |
| 80 | if expression == "${}" && len(refs) == 1 && refs[0].Type == workflowapi.String { |
| 81 | return refs[0], nil |
| 82 | } |
| 83 | |
| 84 | var b strings.Builder |
| 85 | parts := placeholderRE.Split(expression, -1) |
| 86 | for i, part := range parts { |
| 87 | b.WriteString(part) |
| 88 | if i < len(refs) { |
| 89 | b.WriteString(refs[i].AsString()) |
| 90 | } |
| 91 | } |
no test coverage detected