CompileOptions returns options for the standard CEL function declarations and macros.
()
| 158 | |
| 159 | // CompileOptions returns options for the standard CEL function declarations and macros. |
| 160 | func (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. |
| 202 | func (*stdLibrary) ProgramOptions() []ProgramOption { |
nothing calls this directly
no test coverage detected