Open anderseknert opened 1 year ago
The proposed rego.Data
similar to rego.Load
, rego.LoadBundle
and rego.ParsedBundle
would require a transaction to be passed as well. Then should be just a write call on the store as part of preparing the query.
I'm using both rego.Load
and rego.ParsedBundle
without passing any transaction. I'm not sure I follow :)
I was referring to this comment where you set the store and that this would apply to rego.Data
as well.
Ah, I see. Yes, that'd be the same, but the most important point here is that you shouldn't need to set the store or transactions unless you have special requirements that necessitate that, and just throwing some random data in for evaluation should not be one.
But then this would make it different than rego.ParsedBundle
for instance since in the rego.ParsedBundle
case you'd actually write the bundle contents to the store. But that's not how you imagine rego.Data
working, correct?
No, I want it to be written to the store, just like when using those other helper functions 🙂
I just want to do so without the ceremony of having to provide storage and/or a transaction, just like the other helpers allow me to avoid. Example:
r := rego.New(
rego.Query("data.example.users[0].likes"),
rego.Data(map[string]any{"foo": "bar"}),
rego.ParsedBundle(&b),
)
This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. Although currently inactive, the issue could still be considered and actively worked on in the future. More details about the use-case this issue attempts to address, the value provided by completing it or possible solutions to resolve it would help to prioritize the issue.
This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. Although currently inactive, the issue could still be considered and actively worked on in the future. More details about the use-case this issue attempts to address, the value provided by completing it or possible solutions to resolve it would help to prioritize the issue.
Having to create a storage object, and possibly a transaction, in order to just add some data for evaluation using the Go API is a chore, and not intuitive unless you happen to know about it. It would be great if we added a
rego.Data
function that would allow passing a map to populate thedata
object.(There's a longer story around issues with transactions and concurrency, but I'll save that for another issue)