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

Function exprValueToRefValue

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

Source from the content-addressed store, hash-verified

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