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

Method CompileOptions

cel/library.go:160–199  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

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