Commit Graph

55 Commits

Author SHA1 Message Date
Philip Conrad 6b7ede0ee0 cmd/exec: Add timeout flag to help prevent infinite hangs. (#6633)
This commit adds a `--timeout` duration flag to the `opa exec` CLI command.
This flag helps out in use cases such as CI, where stalling indefinitely
is undesirable behavior.

Fixes: #6613

Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
2024-03-18 12:22:41 -04:00
cli-docs-updater c779345458 docs: Update generated CLI docs 2024-03-15 10:01:22 +00:00
cli-docs-updater 29b98a5c04 docs: Update generated CLI docs 2024-01-24 14:44:18 +00:00
cli-docs-updater b1261ba828 docs: Update generated CLI docs 2024-01-23 22:22:04 +00:00
cli-docs-updater f04636adc2 docs: Update generated CLI docs 2023-12-20 10:00:46 +00:00
Johan Fylling 38c2f0c5e0 Adding --v1-compatible flag to build, opa eval (#6478)
* ast+cmd+rego: Adding `--rego-v1` flag to `opa eval`

Fixes: #6463
Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* Adding `--rego-v1` flag to `opa build`

Fixes: #6463
Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* Formatting PE support modules to comply with rego-v1 when required

Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* Removing rego.v1 import when formatting for rego-v1 (not rego-v0-compat-v1)

Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* touch up

Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* Fixing linting issues

Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* Consolidating `Bundle.FormatModules()` and `Bundle.FormatModulesForRegoVersion()`

Suggested by @ashutosh-narkar

Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* Adding descriptions to `RegoVersion`

Requested by @ashutosh-narkar

Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* Using `--v1-compatible` flag instead of `--rego-v1`

Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* Updating docs

Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* Reintroducing `ParserOptions.RegoV1Compatible` to avoid breaking change

Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* cmd & tester

Adding `--v1-compatible` flag to `opa test`

Fixes: #6463
Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* Adding `--v1-compatible` flag to `opa fmt`

Fixes: #6463
Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* Adding `--v1-compatible` flag to `opa check`

Fixes: #6463
Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* Making linter happy

Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* Review modifications suggested by @ashutosh-narkar

* Changing `ParserOptions.RegoV1Compatible` take precedence over `ParserOptions.RegoVersion`
* Fixing comment in test
* Updating `fmt --rego-v1` CLI description

Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* Review modifications suggested by @ashutosh-narkar

* Changing `ParserOptions.RegoV1Compatible` take precedence over `ParserOptions.RegoVersion`
* Fixing comment in test
* Updating `fmt --rego-v1` CLI description
* Adding back `Opts.RegoV1` and deprecating.
  * Making `Opts.RegoV1` take precedence over `Opts.RegoVersion`

Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* Review modifications suggested by @ashutosh-narkar

* Changing `ParserOptions.RegoV1Compatible` take precedence over `ParserOptions.RegoVersion`
* Fixing comment in test
* Updating `fmt --rego-v1` CLI description
* Adding back `Opts.RegoV1` and deprecating.
  * Making `Opts.RegoV1` take precedence over `Opts.RegoVersion`
* `TestPartialWitRegoV1` -> `TestPartialWithRegoV1`

Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* Review modifications suggested by @ashutosh-narkar

* Changing `ParserOptions.RegoV1Compatible` take precedence over `ParserOptions.RegoVersion`
* Fixing comment in test
* Updating `fmt --rego-v1` CLI description
* Adding back `Opts.RegoV1` and deprecating.
  * Making `Opts.RegoV1` take precedence over `Opts.RegoVersion`
* `TestPartialWitRegoV1` -> `TestPartialWithRegoV1`
* removing `Println` in test

Signed-off-by: Johan Fylling <johan.dev@fylling.se>

* Review modifications suggested by @ashutosh-narkar

* Changing `ParserOptions.RegoV1Compatible` take precedence over `ParserOptions.RegoVersion`
* Fixing comment in test
* Updating `fmt --rego-v1` CLI description
* Adding back `Opts.RegoV1` and deprecating.
  * Making `Opts.RegoV1` take precedence over `Opts.RegoVersion`
* `TestPartialWitRegoV1` -> `TestPartialWithRegoV1`
* removing `Println` in test
* Updating docs with per-command behavioural descriptions for `--v1-compatible`.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>

---------

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-12-20 10:59:14 +01:00
Johan Fylling b9398bf1ac docs: Updating Rego examples in docs to be 1.0 compliant (#6444)
* Updating Rego examples in docs to be 1.0 compliant

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-12-15 13:51:49 +01:00
cli-docs-updater 79271563e9 docs: Update generated CLI docs 2023-11-30 10:38:32 +00:00
cli-docs-updater 26a02e4e20 docs: Update generated CLI docs 2023-11-30 10:01:37 +00:00
cli-docs-updater 132cc4b752 docs: Update generated CLI docs 2023-10-26 17:53:15 +00:00
Ashutosh Narkar a470a21aad Rename --future-compat CLI flag
This change renames the `--future-compat` CLI flag on `opa run` to `v1-compatible`.
The latter is clear that it's a declaration that
gated features are compatible with a v1 version of OPA.

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2023-10-26 10:50:50 -07:00
cli-docs-updater 16e2ef4022 docs: Update generated CLI docs 2023-10-18 15:58:59 +00:00
cli-docs-updater bb62835460 docs: Update generated CLI docs 2023-09-11 22:36:13 +00:00
cli-docs-updater 5dc378269f docs: Update generated CLI docs 2023-08-21 09:32:20 +00:00
Ronnie-personal c3854aa6ae feat(cmd): Adding fail-non-empty flag (#6153)
Add fail-non-empty flag to opa exec

Signed-off-by: Ronnie Personal <76408835+Ronnie-personal@users.noreply.github.com>
2023-08-21 11:30:25 +02:00
cli-docs-updater 57c4daa7fa docs: Update generated CLI docs 2023-07-19 08:10:54 +00:00
cli-docs-updater 1448abfbd7 docs: Update generated CLI docs 2023-07-19 07:41:40 +00:00
cli-docs-updater 191a653893 docs: Update generated CLI docs 2023-06-25 16:44:45 +00:00
cli-docs-updater e9190cabee docs: Update generated CLI docs 2023-06-07 00:01:40 +00:00
cli-docs-updater 119794ddce docs: Update generated CLI docs 2023-06-02 10:23:46 +00:00
cli-docs-updater 855c12dc19 docs: Update generated CLI docs 2023-05-16 18:45:43 +00:00
cli-docs-updater a01a660706 docs: Update generated CLI docs 2023-05-02 16:09:37 +00:00
cli-docs-updater 46d0f05923 docs: Update generated CLI docs 2023-03-09 09:51:45 +00:00
cli-docs-updater 15ecb99d96 docs: Update generated CLI docs 2023-02-21 12:48:05 +00:00
Johan Fylling d0c50c35f1 docs: Updating entrypoint documentation
with note about transitive dependencies enumerated as "extra" entrypoints.

Fixes: #5565
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2023-01-23 11:31:15 -08:00
Charlie Egan ac64e78c69 topdown/rego: Add BuiltinErrorList support to rego package, add to eval command (#5487)
```
$ cat pol.rego
package play

this_errors(number) := result {
        result := number / 0
}

this_errors_too(number) := result {
        result := number / 0
}

res1 := this_errors(1)

res2 := this_errors_too(1)

$ go run main.go eval --show-builtin-errors -d pol.rego data.play
{
  "errors": [
    {
      "message": "div: divide by zero",
      "code": "eval_builtin_error",
      "location": {
        "file": "pol.rego",
        "row": 4,
        "col": 12
      }
    },
    {
      "message": "div: divide by zero",
      "code": "eval_builtin_error",
      "location": {
        "file": "pol.rego",
        "row": 8,
        "col": 12
      }
    }
  ],
  "result": [
    {
      "expressions": [
        {
          "value": {},
          "text": "data.play",
          "location": {
            "row": 1,
            "col": 1
          }
        }
      ]
    }
  ]
}
```

Signed-off-by: Charlie Egan <charlieegan3@users.noreply.github.com>
2023-01-03 13:25:49 +00:00
cli-docs-updater db168a22b8 docs: Update generated CLI docs 2022-11-15 08:38:13 +00:00
Peter Macdonald 77b6b3f7cb Adding strict flag to opa eval (#5228)
You can now enable strict mode with `opa eval` by passing `--strict` (`-S`).

Fixes #5182.

Signed-off-by: Peter Macdonald <macdonald.peter90@gmail.com>
2022-11-15 09:35:58 +01:00
cli-docs-updater c067f1deda docs: Update generated CLI docs 2022-11-02 08:21:39 +00:00
cli-docs-updater a86973763d docs: Update generated CLI docs 2022-11-01 17:51:57 +00:00
cli-docs-updater fff3e0aeff docs: Update generated CLI docs 2022-10-26 08:45:26 +00:00
Byron Lagrone 235ee309da cmd/exec: add --fail and --fail-defined flags (#5295)
Adds the ability to exit with a non-zero exit code for 'opa exec' by adding the
--fail and --fail-defined flags matching their respective behaviors in 'opa eval':

- Setting the --fail-defined flag allows exit of opa exec with a zero code if all
   results are undefined and there are no errors, or a non-zero code in the
   event of any defined results and/or errors.
   On non-zero exits the error message includes the number of failures/errors
   as well as a reference to the --fail-defined flag being set.
- The --fail flag behaves as the inverse of --fail-defined.

Fixes: #5007

Signed-off-by: Byron Lagrone <byron.lagrone@seqster.com>
2022-10-26 10:43:07 +02:00
cli-docs-updater 476e04f377 docs: Update generated CLI docs 2022-10-24 18:37:46 +00:00
Philip Conrad e2eabe88c1 ast+compile+cmd: Support entrypoint annotations. (#5246)
This commit adds support to the `compile` package for extracting
entrypoints from Rego `entrypoint` metadata annotations. The new
entrypoint annotations can be applied to any valid entrypoint target,
e.g. rules and packages.

An example policy using the new entrypoint annotations:

    package test

    # METADATA
    # entrypoint: true
    allow {
        input.x
    }

The `build` and `eval` CLI commands have been updated so that they do
not require an entrypoint to be explicitly provided with `-e`, so long
as at least one valid rule/package is marked with an entrypoint
annotation.

The new feature is additive; entrypoints can still be explicitly
provided to these commands by `-e`, and those will be used alongside the
entrypoints discovered from the metadata annotations.

Fixes: #3459

Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
2022-10-24 14:35:17 -04:00
Jasper Van der Jeugt a56c231269 feature: add UnifyOp to tracer events (#5203)
This would be useful for us for two immediate use cases:

1.  Show how and why rules failed in more detail in verbose tooling,
    we can show the unification happening step by step.
2.  We can trace which parts of the input document were used, if we
    add `Location` info those terms.

However, I think it's generally useful for debugging tools.

This increases verbosity in the explain logs, so we decided to add a new explain
mode `debug` in addition to the existing `full`, `notes`, `fails`, `off` modes.
This can be set using the `--explain=debug` flag on the CLI, or by using `trace
debug` in the REPL.

Signed-off-by: Jasper Van der Jeugt <m@jaspervdj.be>
2022-10-10 11:57:31 +02:00
cli-docs-updater fc328b43e1 docs: Update generated CLI docs 2022-09-23 18:38:53 +00:00
Ashutosh Narkar 6c6494e42e internal/report: Include heap usage in the telemetry report
Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2022-09-23 11:36:53 -07:00
cli-docs-updater f266848ffe docs: Update generated CLI docs 2022-09-21 12:32:01 +00:00
cli-docs-updater 1919dc07f0 docs: Update generated CLI docs 2022-09-20 12:52:18 +00:00
cli-docs-updater b0579bc16a docs: Update generated CLI docs 2022-08-29 12:26:03 +00:00
Sergey Vilgelm 5e51af9244 logger: Configure timestamp format (#5050)
With this, we allow the user to configure the logger's timestamp format by:
* cli argument `log-timestamp-format`
* environment variable `OPA_LOG_TIMESTAMP_FORMAT`

Fixes #2413.

Signed-off-by: Sergey Vilgelm <sergey@vilgelm.com>
2022-08-29 14:23:48 +02:00
cli-docs-updater 54041985ec docs: Update generated CLI docs 2022-08-23 08:34:05 +00:00
cli-docs-updater eaea98c4ad docs: Update generated CLI docs 2022-08-22 21:27:56 +00:00
cli-docs-updater 3694eb1341 docs: Update generated CLI docs 2022-06-22 18:32:18 +00:00
cli-docs-updater 1ff8f00729 docs: Update generated CLI docs 2022-05-24 21:12:21 +00:00
Anders Eknert af5141bfa0 Update docs to prefer := over = (#4706)
Seems like we missed this in a "few" places :)

Signed-off-by: Anders Eknert <anders@eknert.com>
2022-05-24 23:10:11 +02:00
IoannisMatzaris d71e3bb6c2 cmd/capabilities: expose capabilities through CLI (#4588)
There is a new command argument "capabilities". With this, it is
possible to print the current capabilities version, show all
capabilities versions & print any capabilities version, without the need
of a file. Moreover, for the other commands which use the --capabilities
flag, it is possible to give only the version number, without specifying
a file. However, there are no breaking changes for those who use the
capabilities file as an input for the flag. Unit tests were also
written, in order to test the new argument and the changes made in ast.

Fixes: #4236

Signed-off-by: IoannisMatzaris <matzarisioannis@gmail.com>
2022-04-26 10:57:48 +02:00
cli-docs-updater aaf167db99 docs: Update generated CLI docs 2022-04-20 16:29:21 +00:00
Torin Sandall 54827f3ef4 docs/content: Update docs to use := at the file-level
This partially addresses #4599.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2022-04-20 09:27:39 -07:00
cli-docs-updater 521cd2369c docs: Update generated CLI docs 2022-03-03 10:20:32 +00:00