valueToJSON converts the CEL type to a protobuf JSON representation and marshals the result to a string.
(val ref.Val)
| 272 | // valueToJSON converts the CEL type to a protobuf JSON representation and |
| 273 | // marshals the result to a string. |
| 274 | func valueToJSON(val ref.Val) string { |
| 275 | v, err := val.ConvertToNative(reflect.TypeOf(&structpb.Value{})) |
| 276 | if err != nil { |
| 277 | glog.Exit(err) |
| 278 | } |
| 279 | marshaller := protojson.MarshalOptions{Indent: " "} |
| 280 | bytes, err := marshaller.Marshal(v.(proto.Message)) |
| 281 | if err != nil { |
| 282 | glog.Exit(err) |
| 283 | } |
| 284 | return string(bytes) |
| 285 | } |
| 286 | |
| 287 | var ( |
| 288 | emptyClaims = make(map[string]string) |
nothing calls this directly
no test coverage detected