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

Update parser to support rules of the form <var> = <term containing ref> #192

Closed
tsandall opened this issue Dec 9, 2016 · 0 comments
Closed

Comments

@tsandall
Copy link
Member

tsandall commented Dec 9, 2016

Rules can be written in the form <var> = <ground term>. This is useful for defining constants; it would be nice if we could do the same with terms containing refs. Currently, the parser will return an error because it deems the term as being non-ground (since references have not been resolved yet).

One solution would be to update the parser to allow non-ground terms. If the user did include a variable in the value and that variable was not eventually resolved, the compiler should catch the error when performing the safety checks on the head.

Example parse error:

torin:~$ opa run test.rego
test.rego:7: expected rule (annotations_versioned = {
    "metadata": {
        "annotations": annotations,
        "resourceVersion": object.metadata.resourceVersion
    }
} must be declared inside a rule)

Example input:

package io.k8s

import object

annotations = {}

annotations_versioned = {
    "metadata": {
        "annotations": annotations,
        "resourceVersion": object.metadata.resourceVersion
    }
}
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

1 participant