--
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/21ea19bb-48a5-4a0c-8b08-cb7f47276e7b%40googlegroups.com.
decisions, err := enforcer.Evaluate(map[string]interface{}{
"User":"srihari",
"Service":"Storage",
"Resource":"/Get",
"Usergroups": []string{"service.storage.admin","data.default.admin"},
})
Usergroups.exists(u,groups_to_match_storage_get.exists(d,u==d))
getUserGroups(User).exists(u,groups_to_match_storage_get.exists(d,u==d))
getUserGroups = policy.Functions(&functions.Overload{
Operator: "get_usergroups_string",
Unary: func(User ref.Val) interface{} {
list:= []string{"A","B"}
return list
},
})
Hi, Rucha!If you don't mind a quadratic-time solution, i.e. if your lists are small or if your performance expectations are loose, you can use nested macros.user.exists(u, data.exists(d, u == d))Otherwise, if you want a more efficient algorithm (e.g. pre-sorting both lists and using a linear-time match finder), you'd have to implement it yourself.Jim
On Mon, May 4, 2020 at 8:27 AM Rucha Deshpande <rborg...@gmail.com> wrote:
Hello All,--I am looking to find an optimized way of matching items in 2 lists. For example:
User DataGroup1 Group1Group2 Group5Group3 Group6I want to evaluate whether an element from User Groups List has a matching element in Data Groups list.Here Group1 matches, so result would be true.Is there an optimized CEL way of doing this?or do I have to write an iterator?Thank you!
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-...@googlegroups.com.
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/1e7a5017-02b5-45e6-b0a4-5c80d385f7ea%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cel-go-discuss/1e7a5017-02b5-45e6-b0a4-5c80d385f7ea%40googlegroups.com.