Closed danlinxie closed 2 weeks ago
Hi @danlinxie,
You may want to consider using ext/native.go
as a way of enabling the use of Go structs in CEL which is ext.NativeTypes(&UserAgent{})
where the UserAgent
refers to your Go struct.
You may find this test setup useful:
-Tristan
Thank you @TristonianJones! This is working great:
env, err := cel.NewEnv(
ext.NativeTypes(reflect.TypeOf(&UserAgent{})),
cel.Variable("UserAgent", cel.ObjectType("main.UserAgent")),
)
Hi folks! I'm new to the library and curious if there's any way to make CEL support a native Go struct in program environment?
Here's my use case in mind:
From my understand, I'd have to generate protobuf go struct from something like:
And apply it to program env:
Is this the expected setup for using a strongly typed object with CEL? or there is something simpler (e.g. not involving protobuf)?