Skip to content

Commit

Permalink
docs: Update name of v0-v1 flag
Browse files Browse the repository at this point in the history
Follows open-policy-agent#7225

Signed-off-by: Charlie Egan <charlie@styra.com>
  • Loading branch information
charlieegan3 committed Dec 18, 2024
1 parent adba53c commit 4f55dca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions docs/content/v0-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ to migrate their Rego to be compatible with OPA v1.0 using the below tooling opt

1. The `rego.v1` import makes OPA apply all restrictions that are enforced by default in OPA v1.0.
If a Rego module imports `rego.v1`, it means applicable `future.keywords` imports are implied. It is illegal to import both `rego.v1` and `future.keywords` in the same module.
2. The `--rego-v1` flag on the `opa fmt` command will rewrite existing modules to use the `rego.v1` import instead of `future.keywords` imports.
3. The `--rego-v1` flag on the `opa check` command will check that either the `rego.v1` import or applicable `future.keywords` imports are present if any of the `in`, `every`, `if` and `contains` keywords are used in a module.
2. The `--v0-v1` flag on the `opa fmt` command will rewrite existing modules to use the `rego.v1` import instead of `future.keywords` imports. Use `--rego-v1` for v0 OPA versions.
3. The `--v0-v1` flag on the `opa check` command will check that either the `rego.v1` import or applicable `future.keywords` imports are present if any of the `in`, `every`, `if` and `contains` keywords are used in a module. Use `--rego-v1` for v0 OPA versions.

### v0.x compatibility mode in the OPA binary

Expand All @@ -42,17 +42,19 @@ releases:
- `eval`: supports Rego v0.x syntax modules, use of `import rego.v1` is optional.
- `exec`: supports Rego v0.x syntax modules, use of `import rego.v1` is optional.
- `fmt`*: formats modules to be compatible with OPA v0.x syntax. See note about
`--rego-v1` flag below.
`--v0-v1`/`--rego--v1` flag below.
- `inspect`: supports Rego v0.x syntax modules, use of `import rego.v1` is optional.
- `parse`: supports Rego v0.x syntax modules, use of `import rego.v1` is optional.
- `run`: supports modules (including discovery bundle) using Rego v0.x syntax, use of `import rego.v1` is optional. Binds server listeners to all interfaces by default, rather than localhost.
- `test`: supports Rego v0.x syntax modules, use of `import rego.v1` is optional.

Note (*): the `check` and `fmt` commands also support the `--rego-v1` flag,
Note (*): the `check` and `fmt` commands also support the `--v0-v1` flag,
which will check/format Rego modules as if compatible with the Rego syntax of
_both_ the old 0.x OPA version and current OPA v1.0.
_both_ the old 0.x OPA version and current OPA v1.0. This flag is called
`--rego-v1` in v0 OPA versions.

Note (*): the `--rego-v1` flag is not supported before OPA `v0.59.0`.
Note (*): the `--rego-v1` flag is not supported before OPA `v0.59.0` and was
renamed to `--v0-v1` as part of the OPA 1.0 release.

Note (*): Pre v1.0 versions of OPA also support a comparable `--v1-compatible`
flag which can be used to produce and consume Rego v1 bundles. See
Expand Down
2 changes: 1 addition & 1 deletion docs/content/v0-upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ OPA v1.0. These steps are largely based on the process outlined in this
that might make it incompatible with OPA v1.0 such as the use of deprecated
built-ins or duplicate imports.
3. Automatically reformat your code for OPA v1.0 with
`opa fmt --write --rego-v1`.
`opa fmt --write --v0-v1` (`opa fmt --rego-v1` for v0 OPA versions)
4. `regal lint`, the [Regal linter](/integrations/regal/) has many more rules to
test for issues in Rego code that can lead to errors, poor performance or
unexpected behaviour.
Expand Down

0 comments on commit 4f55dca

Please sign in to comment.