1

I have been playing with the OPA Rego Playground. Nice tool. Very powerful.

The default sort is alphabetical. But I'd like to sort the output in the same order as defined in the policy

I saw some switches for the opa command line tool. --profile-sort So I tried to put this profile-sort = "line" in the policy. But it didn't work.

Any ideas on how to make it sort by "line"?

Tom Turner
  • 11
  • 2

1 Answers1

1

The output from the policy evaluated by the Playground is an object, and those are almost always "unsorted" in that order of the keys shouldn't matter. If you're using OPA in a more realistic context you'd be free to sort the result however you wanted after receiving the decision from OPA.

Also note that Rego is not an imperative language. There is no guarantees that the order of which you've added rules to a policy will be the order that OPA evaluates them.

Devoops
  • 2,018
  • 8
  • 21