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

Method CompileOptions

cel/library.go:162–204  ·  view source on GitHub ↗

CompileOptions returns options for the standard CEL function declarations and macros.

()

Source from the content-addressed store, hash-verified

160
161// CompileOptions returns options for the standard CEL function declarations and macros.
162func (lib *stdLibrary) CompileOptions() []EnvOption {
163 funcs := stdlib.Functions()
164 macros := StandardMacros
165 if lib.subset != nil {
166 subMacros := []Macro{}
167 for _, m := range macros {
168 if lib.subset.SubsetMacro(m.Function()) {
169 subMacros = append(subMacros, m)
170 }
171 }
172 macros = subMacros
173 subFuncs := []*decls.FunctionDecl{}
174 for _, fn := range funcs {
175 if f, include := lib.subset.SubsetFunction(fn); include {
176 subFuncs = append(subFuncs, f)
177 }
178 }
179 funcs = subFuncs
180 }
181 return []EnvOption{
182 func(e *Env) (*Env, error) {
183 var err error
184 if err = lib.subset.Validate(); err != nil {
185 return nil, err
186 }
187 if len(funcs) > 0 {
188 e.ensureMutableFunctions()
189 }
190 for _, fn := range funcs {
191 existing, found := e.functions[fn.Name()]
192 if found {
193 fn, err = existing.Merge(fn)
194 if err != nil {
195 return nil, err
196 }
197 }
198 e.functions[fn.Name()] = fn
199 }
200 return e, nil
201 },
202 Macros(macros...),
203 }
204}
205
206// ProgramOptions returns function implementations for the standard CEL functions.
207func (*stdLibrary) ProgramOptions() []ProgramOption {

Callers

nothing calls this directly

Calls 9

FunctionsFunction · 0.92
SubsetMacroMethod · 0.80
SubsetFunctionMethod · 0.80
MergeMethod · 0.80
MacrosFunction · 0.70
FunctionMethod · 0.65
ValidateMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected