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

opa fmt: will format ref head rules when they're not needed, causing back compat issues #5449

Closed
srenatus opened this issue Dec 7, 2022 · 0 comments · Fixed by #5450
Closed

Comments

@srenatus
Copy link
Contributor

srenatus commented Dec 7, 2022

package demo

policies = ["first"]

demo_rule["first_policy"] = arr[0] {
	count(policies) == 1
	arr := [x | policies[x]]
}

⬇️ opa fmt

package demo

policies = ["first"]

demo_rule.first_policy = arr[0] {
	count(policies) == 1
	arr := [x | policies[x]]
}

In this case, the output will not work on OPA version that don't know ref heads. But if the input policy is OK with a version of OPA, then the formatted policy must be, too.

@srenatus srenatus added the bug label Dec 7, 2022
@srenatus srenatus added this to Backlog in Open Policy Agent via automation Dec 7, 2022
@srenatus srenatus moved this from Backlog to In Progress in Open Policy Agent Dec 7, 2022
srenatus added a commit to srenatus/opa that referenced this issue Dec 7, 2022
Before, we'd end up formatting

    ps["foo"] = "bar" { true }

as

    ps.foo = "bar" { true }

and older OPA version know how to parse the former, but not
the latter.

Fixes open-policy-agent#5449.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Open Policy Agent automation moved this from In Progress to Done Dec 7, 2022
srenatus added a commit to srenatus/opa that referenced this issue Dec 7, 2022
…cy-agent#5450)

Before, we'd end up formatting

    ps["foo"] = "bar" { true }

as

    ps.foo = "bar" { true }

and older OPA version know how to parse the former, but not
the latter.

Fixes open-policy-agent#5449.

Also includes:
* format: pass internal options via struct; because adding a third (in some cases
   fifth) boolean argument just didn't seem right.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
srenatus added a commit that referenced this issue Dec 7, 2022
Before, we'd end up formatting

    ps["foo"] = "bar" { true }

as

    ps.foo = "bar" { true }

and older OPA version know how to parse the former, but not
the latter.

Fixes #5449.

Also includes:
* format: pass internal options via struct; because adding a third (in some cases
   fifth) boolean argument just didn't seem right.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
srenatus added a commit to srenatus/opa that referenced this issue Dec 7, 2022
…cy-agent#5450)

Before, we'd end up formatting

    ps["foo"] = "bar" { true }

as

    ps.foo = "bar" { true }

and older OPA version know how to parse the former, but not
the latter.

Fixes open-policy-agent#5449.

Also includes:
* format: pass internal options via struct; because adding a third (in some cases
   fifth) boolean argument just didn't seem right.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
srenatus added a commit that referenced this issue Dec 7, 2022
Before, we'd end up formatting

    ps["foo"] = "bar" { true }

as

    ps.foo = "bar" { true }

and older OPA version know how to parse the former, but not
the latter.

Fixes #5449.

Also includes:
* format: pass internal options via struct; because adding a third (in some cases
   fifth) boolean argument just didn't seem right.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

1 participant