()
| 91 | } |
| 92 | |
| 93 | func (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 | |
| 120 | func (*encoderLib) ProgramOptions() []cel.ProgramOption { |
| 121 | return []cel.ProgramOption{} |
nothing calls this directly
no test coverage detected