fugue / fregot

Fugue Rego Toolkit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fregot doesn't recognize non-rego files even when OPA does

kmcquade opened this issue · comments

First of all - very cool looking tool. It looks like it will solve a lot of my pain points with Rego.

Now to the issue I'm having. I have one of my policy files loading a YAML file as a data source. It looks like this:

package main
import data.exceptions.filename # this refers to the file at path policy/exceptions/filename.yaml
import data.common # just where I store some common functions

a_function (param) {
  common.list_contains_value(exceptions.filename.firstfield, "valuetocheck")
}

This works fine in good ol' opa test. But when I try to run repl or test commands with fregot on these files, I get this error:

fregot repl policy/main.rego policy/main_test.rego policy/common.rego policy/exceptions/filename.yaml --watch
fregot (interpreter error):
  Unknown rego file extension: policy/exceptions/filename.yaml , expected .rego or .bundle.rego

And of course, when I try to run it without specifying the YAML file, it doesn't know what I'm referring to.


fregot repl policy/main.rego policy/main_test.rego policy/common.rego --watch

fregot (compile error):
  "policy/main.rego" (line 10, column 3):
  unknown variable:

    10|   common.list_contains_value(exceptions[filename][firstfield], "valuetocheck")
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  Undefined variable: exceptions

What's the root cause? Am I doing something wrong? Or is this something you can fix?

Help would be much appreciated. Thanks!

Thanks @kmcquade!

You're not doing anything wrong -- loading YAML or JSON files is currently only supported as input and not as data, but it should be a relatively light lift to add this. I'll try to get it in next week.

This turned out to be a bit more complex than I initially thought and requires storing rules / data in a full tree rather than just a collection of packages. This work is ongoing in #138.

Fantastic. I appreciate the work on this @jaspervdj-luminal

Thanks for your patience! This should be fixed in v0.7.0 -- please reopen this ticket if there's still something wrong.