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

Method CompileOptions

ext/encoders.go:96–127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected