isCELConcatCall tests whether the expression is a concat function (+) with string, placeholder, or other concat call arguments.
(e ast.Expr)
| 766 | // isCELConcatCall tests whether the expression is a concat function (+) with string, placeholder, or |
| 767 | // other concat call arguments. |
| 768 | func isCELConcatCall(e ast.Expr) bool { |
| 769 | switch e.Kind() { |
| 770 | case ast.CallKind: |
| 771 | call := e.AsCall() |
| 772 | if call.Target().Kind() != ast.UnspecifiedExprKind { |
| 773 | return false |
| 774 | } |
| 775 | if call.FunctionName() != operators.Add { |
| 776 | return false |
| 777 | } |
| 778 | for _, arg := range call.Args() { |
| 779 | if !isCELStringExpr(arg) { |
| 780 | return false |
| 781 | } |
| 782 | } |
| 783 | return true |
| 784 | case ast.UnspecifiedExprKind, ast.ComprehensionKind, ast.IdentKind, ast.ListKind, ast.LiteralKind, ast.MapKind, ast.SelectKind, ast.StructKind: |
| 785 | // appeasing the linter :) |
| 786 | } |
| 787 | return false |
| 788 | } |
| 789 | |
| 790 | // isCELStringListLiteral returns whether the expression resolves to a list literal |
| 791 | // containing only string constants or a placeholder call. |
no test coverage detected