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

Function exprValueToRefValue

conformance/conformance_test.go:149–173  ·  view source on GitHub ↗
(adapter types.Adapter, ev *valuepb.ExprValue)

Source from the content-addressed store, hash-verified

147}
148
149func exprValueToRefValue(adapter types.Adapter, ev *valuepb.ExprValue) (ref.Val, error) {
150 switch ev.Kind.(type) {
151 case *valuepb.ExprValue_Value:
152 return cel.ProtoAsValue(adapter, ev.GetValue())
153 case *valuepb.ExprValue_Error:
154 // An error ExprValue is a repeated set of statuspb.Status
155 // messages, with no convention for the status details.
156 // To convert this to a types.Err, we need to convert
157 // these Status messages to a single string, and be
158 // able to decompose that string on output so we can
159 // round-trip arbitrary ExprValue messages.
160 // TODO(jimlarson) make a convention for this.
161 return types.NewErr("XXX add details later"), nil
162 case *valuepb.ExprValue_Unknown:
163 var unk *types.Unknown
164 for _, id := range ev.GetUnknown().GetExprs() {
165 if unk == nil {
166 unk = types.NewUnknown(id, nil)
167 }
168 unk = types.MergeUnknowns(types.NewUnknown(id, nil), unk)
169 }
170 return unk, nil
171 }
172 return nil, errors.New("unknown ExprValue kind")
173}
174
175func diffType(want proto.Message, t *cel.Type) (string, error) {
176 got, err := types.TypeToProto(t)

Callers 1

conformanceTestFunction · 0.85

Calls 6

ProtoAsValueFunction · 0.92
NewErrFunction · 0.92
NewUnknownFunction · 0.92
MergeUnknownsFunction · 0.92
GetValueMethod · 0.80
NewMethod · 0.80

Tested by

no test coverage detected