MCPcopy Create free account
hub / github.com/bytebase/bytebase / validateCELExpr

Function validateCELExpr

backend/common/cel.go:190–209  ·  view source on GitHub ↗
(expression *expr.Expr, conditionCELAttributes []cel.EnvOption)

Source from the content-addressed store, hash-verified

188}
189
190func validateCELExpr(expression *expr.Expr, conditionCELAttributes []cel.EnvOption) (cel.Program, error) {
191 if expression == nil || expression.Expression == "" {
192 return nil, nil
193 }
194 e, err := cel.NewEnv(
195 conditionCELAttributes...,
196 )
197 if err != nil {
198 return nil, connect.NewError(connect.CodeInternal, err)
199 }
200 ast, issues := e.Compile(expression.Expression)
201 if issues != nil && issues.Err() != nil {
202 return nil, connect.NewError(connect.CodeInvalidArgument, issues.Err())
203 }
204 prog, err := e.Program(ast)
205 if err != nil {
206 return nil, connect.NewError(connect.CodeInvalidArgument, err)
207 }
208 return prog, nil
209}
210
211// QueryExportFactors is the factors for query and export.
212type QueryExportFactors struct {

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected