@@ -102,12 +102,14 @@ func AstToString(a *Ast) (string, error) {
102
102
return parser .Unparse (a .impl .Expr (), a .impl .SourceInfo ())
103
103
}
104
104
105
- // RefValueToValue converts between ref.Val and api.expr.Value.
105
+ // RefValueToValue converts between ref.Val and google. api.expr.v1alpha1 .Value.
106
106
// The result Value is the serialized proto form. The ref.Val must not be error or unknown.
107
107
func RefValueToValue (res ref.Val ) (* exprpb.Value , error ) {
108
108
return ValueAsAlphaProto (res )
109
109
}
110
110
111
+ // ValueAsAlphaProto converts between ref.Val and google.api.expr.v1alpha1.Value.
112
+ // The result Value is the serialized proto form. The ref.Val must not be error or unknown.
111
113
func ValueAsAlphaProto (res ref.Val ) (* exprpb.Value , error ) {
112
114
canonical , err := ValueAsProto (res )
113
115
if err != nil {
@@ -118,6 +120,8 @@ func ValueAsAlphaProto(res ref.Val) (*exprpb.Value, error) {
118
120
return alpha , err
119
121
}
120
122
123
+ // ValueAsProto converts between ref.Val and cel.expr.Value.
124
+ // The result Value is the serialized proto form. The ref.Val must not be error or unknown.
121
125
func ValueAsProto (res ref.Val ) (* celpb.Value , error ) {
122
126
switch res .Type () {
123
127
case types .BoolType :
@@ -205,11 +209,12 @@ var (
205
209
anyPbType = reflect .TypeOf (& anypb.Any {})
206
210
)
207
211
208
- // ValueToRefValue converts between exprpb .Value and ref.Val.
212
+ // ValueToRefValue converts between google.api.expr.v1alpha1 .Value and ref.Val.
209
213
func ValueToRefValue (adapter types.Adapter , v * exprpb.Value ) (ref.Val , error ) {
210
214
return AlphaProtoAsValue (adapter , v )
211
215
}
212
216
217
+ // AlphaProtoAsValue converts between google.api.expr.v1alpha1.Value and ref.Val.
213
218
func AlphaProtoAsValue (adapter types.Adapter , v * exprpb.Value ) (ref.Val , error ) {
214
219
canonical := & celpb.Value {}
215
220
if err := convertProto (v , canonical ); err != nil {
@@ -218,6 +223,7 @@ func AlphaProtoAsValue(adapter types.Adapter, v *exprpb.Value) (ref.Val, error)
218
223
return ProtoAsValue (adapter , canonical )
219
224
}
220
225
226
+ // ProtoAsValue converts between cel.expr.Value and ref.Val.
221
227
func ProtoAsValue (adapter types.Adapter , v * celpb.Value ) (ref.Val , error ) {
222
228
switch v .Kind .(type ) {
223
229
case * celpb.Value_NullValue :
0 commit comments