Hi,
I'm planning to use CEL in a project, but can't find an example for my use case. What I want to do is to enable expression parsing on an arbitrary incoming JSON message whose internal structure is unknown at compile time of my Go program. For example, one message may be:
{
"eventType" : "type1",
"owner" : "ower_id",
"data" : {
"attr1": "val1",
"attr2": "val2",
...
}
}
while another message maybe:
{
"eventyType" : "type2",
"repository": "repository_name",
"data": {
"attr3": "val3",
"attr4": "val4",
"attr5": [ "...", "..." ]
}
}
I would like to define an incoming message as a variable, and the use it in an expression. For example, the expression may be something like:
message.eventType == "type1"? message.owner: ""
or
message.eventType == "type2"? message.data.attr3: ""
I would also like to support pre-defined variables that the user can provide in a file. I will parse this file to define the variables before calling the expression parser. For example, the variables may be:
owners: [ "owner1", "owner2" ]
It's OK to restrict the variables to JSON supported types. Once I add owners as a pre-defined variable, the expression can then be:
message.owner in owners