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

Rules and input in sub-directory doesn't work #27

Closed
mhausenblas opened this issue Mar 10, 2020 · 3 comments
Closed

Rules and input in sub-directory doesn't work #27

mhausenblas opened this issue Mar 10, 2020 · 3 comments

Comments

@mhausenblas
Copy link

I'm working on mhausenblas/eunomia/ and when I issue the query on the command line, in the respective sub-dir I get the expected result:

opa eval --input input.json --data violations.rego --package violations.eunomia.testing 'rbac_cluster_role'

However, with the VSCode plug-in I get:

// Evaluated package in 763.04µs.
{
  "rbac_cluster_role": []
}

I tried to set opa.roots in settings.json to ${fileDirname} but that didn't help either.

@patrick-east
Copy link
Contributor

I think things are working as intended.

The VSCode integration current looks at the workspace root for a file called input.json which it will use as the input for evaluations. If you open vscode only on the ./test directory it works as expected, for example:

image

image

What would be helpful is if we could adjust the plugin tasks to allow providing a different/custom input document. That seems like the right way to make this work more as expected (along with #26 so that its easier to see what actually was being run)

In the meantime for your project you can always just make custom VSCode tasks like:

.vscode/tasks.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "eval rbac_cluster_role",
            "type": "shell",
            "command": "opa eval --input ./test/input.json --data ./test/violations.rego --package violations.eunomia.testing rbac_cluster_role"
        }
    ]
}

Which you can invoke via the command pallete
image

And get your results in vscode:
image

@patrick-east
Copy link
Contributor

I filed #28 to track adding some way to provide custom input paths.

@mhausenblas
Copy link
Author

Thanks a million for the very speedy follow up and resolution, really appreciate it @patrick-east ... I shall subscribe to #28 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants