How is typeName mapped to exact type in implementation?

23 views
Skip to first unread message

Vyom Yadav

unread,
Apr 29, 2023, 4:51:18 AM4/29/23
to CEL Go Discussion Forum
Hi Folks,

Consider the following snippet: (Explicitly doing it in markdown format)
```go
env, err := cel.NewEnv(
cel.Types(&rpcpb.AttributeContext_Request{}),
cel.Variable("request", cel.ObjectType("google.rpc.context.AttributeContext.Request")),
)
```

In the snippet above, we supply `rpcpb.AttributeContext_Request` and `google.rpc.context.AttributeContext.Request`.

Now rpcpb.AttributeContext_Request(google.golang.org/genproto/googleapis/rpc/context/attribute_context)
nowhere contains `google.rpc.context.AttributeContext.Request` as a variable or anything, the package name `google.rpc.context` is present in the .proto file BUT no in the .pb.go file.

`google.rpc.context.AttributeContext.Request` is present as a comment in generated protobuf file.

I am pretty new to this and am keen to know how this mapping from `google.rpc.context.AttributeContext.Request` ->  `rpcpb.AttributeContext_Request` exactly happens.

I would be grateful if you could explain this to me and provide a link to the actual part of code in the implementation.

Thanking You,
Vyom

Tristan Swadell

unread,
May 30, 2023, 11:41:15 AM5/30/23
to Vyom Yadav, CEL Go Discussion Forum
Hi Vyom,

Sorry for the late reply,

The type-name would be the protobuf type name, so proto package `google.rpc.context` and proto type name `AttributeContext.Request`. 

It's the same syntax you would use when referring to a type-name within another proto file.

-Tristan

--
You received this message because you are subscribed to the Google Groups "CEL Go Discussion Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cel-go-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cel-go-discuss/5c6715fa-8d58-4707-baae-5972a5117f4fn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages