Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different / empty output with "opa deps" depending on output format #4342

Closed
anderseknert opened this issue Feb 11, 2022 · 1 comment · Fixed by #4343
Closed

Different / empty output with "opa deps" depending on output format #4342

anderseknert opened this issue Feb 11, 2022 · 1 comment · Fixed by #4343
Labels

Comments

@anderseknert
Copy link
Member

For some queries, the opa deps command show no output at all unless --format json is chosen.

foo.rego

package foo

x := 5

allow {
    is_foo
}

is_foo {
    x == 1
}
❯ opa deps -d foo.rego data.foo.allow
<no output>
❯ opa deps -d foo.rego -f json data.foo.allow
{
  "virtual": [
    [
      {
        "type": "var",
        "value": "data"
      },
      {
        "type": "string",
        "value": "foo"
      },
      {
        "type": "string",
        "value": "allow"
      }
    ],
    [
      {
        "type": "var",
        "value": "data"
      },
      {
        "type": "string",
        "value": "foo"
      },
      {
        "type": "string",
        "value": "is_foo"
      }
    ],
    [
      {
        "type": "var",
        "value": "data"
      },
      {
        "type": "string",
        "value": "foo"
      },
      {
        "type": "string",
        "value": "x"
      }
    ]
  ]
}

If x := 5 is changed to x := input.x then opa deps show output even without JSON formatting.. presumably since a base document is referenced, but I don't know if that's the only determining factor.

❯ opa deps -d foo.rego data.foo.allow
+----------------+-------------------+
| BASE DOCUMENTS | VIRTUAL DOCUMENTS |
+----------------+-------------------+
| input.x        | data.foo.allow    |
|                | data.foo.is_foo   |
|                | data.foo.x        |
+----------------+-------------------+
@anderseknert
Copy link
Member Author

anderseknert commented Feb 11, 2022

As a side note, the --help output for this command could be improved with an example or two, as it currently says nothing more than "Analyze Rego query dependencies". Also, since it mentions "base documents" and "virtual documents", it would be useful to include an explanation of what that means, or at least link to the docs on the topic.

anderseknert added a commit to anderseknert/opa that referenced this issue Feb 12, 2022
Also, add some content to `opa deps --help`

Fixes open-policy-agent#4342

Signed-off-by: Anders Eknert <anders@eknert.com>
anderseknert added a commit that referenced this issue Feb 12, 2022
Also, add some content to `opa deps --help`

Fixes #4342

Signed-off-by: Anders Eknert <anders@eknert.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant