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

Method CompileOptions

ext/encoders.go:93–118  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

91}
92
93func (lib *encoderLib) CompileOptions() []cel.EnvOption {
94 opts := []cel.EnvOption{
95 cel.Function("base64.decode",
96 cel.Overload("base64_decode_string", []*cel.Type{cel.StringType}, cel.BytesType,
97 cel.UnaryBinding(func(str ref.Val) ref.Val {
98 s := str.(types.String)
99 return bytesOrError(base64DecodeString(string(s)))
100 }))),
101 cel.Function("base64.encode",
102 cel.Overload("base64_encode_bytes", []*cel.Type{cel.BytesType}, cel.StringType,
103 cel.UnaryBinding(func(bytes ref.Val) ref.Val {
104 b := bytes.(types.Bytes)
105 return stringOrError(base64EncodeBytes([]byte(b)))
106 }))),
107 }
108 if lib.version >= 1 {
109 opts = append(opts,
110 cel.Function("json.encode",
111 cel.Overload("json_encode_dyn", []*cel.Type{cel.DynType}, cel.StringType,
112 cel.UnaryBinding(func(val ref.Val) ref.Val {
113 return stringOrError(jsonEncodeValue(val))
114 }))),
115 )
116 }
117 return opts
118}
119
120func (*encoderLib) ProgramOptions() []cel.ProgramOption {
121 return []cel.ProgramOption{}

Callers

nothing calls this directly

Calls 8

FunctionFunction · 0.92
OverloadFunction · 0.92
UnaryBindingFunction · 0.92
bytesOrErrorFunction · 0.85
base64DecodeStringFunction · 0.85
stringOrErrorFunction · 0.85
base64EncodeBytesFunction · 0.85
jsonEncodeValueFunction · 0.85

Tested by

no test coverage detected