MCPcopy Create free account
hub / github.com/cel-expr/cel-go / celIndex

Function celIndex

conformance/conformance_test.go:372–382  ·  view source on GitHub ↗
(mef cel.MacroExprFactory, target ast.Expr, args []ast.Expr)

Source from the content-addressed store, hash-verified

370}
371
372func celIndex(mef cel.MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *cel.Error) {
373 if !isCELNamespace(target) {
374 return nil, nil
375 }
376 index := args[0]
377 if !isNonNegativeInt(index) {
378 return index, mef.NewError(index.ID(), "cel.index requires a single non-negative int constant arg")
379 }
380 indexVal := index.AsLiteral().(types.Int)
381 return mef.NewIdent(fmt.Sprintf("@index%d", indexVal)), nil
382}
383
384func celCompreVar(funcName, varPrefix string) cel.MacroFactory {
385 return func(mef cel.MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *cel.Error) {

Callers

nothing calls this directly

Calls 6

isCELNamespaceFunction · 0.85
isNonNegativeIntFunction · 0.85
NewErrorMethod · 0.65
IDMethod · 0.65
AsLiteralMethod · 0.65
NewIdentMethod · 0.65

Tested by

no test coverage detected