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

Method CompileOptions

cel/library.go:171–213  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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