This also adds a new test step running all testscript txtar archives
on all platforms. Our existing lo-fi binary smoke tests should move to
that eventually.
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
This change allows users that build their own executable or "spin" of
OPA to give it a name, and have it reference itself properly in help
texts.
It's a vanity thing, but I think some people would appreciate it, hat
tip to the international association of pedants.
Signed-off-by: Stephan Renatus <stephan@styra.com>
Co-authored-by: kevinstyra <83973046+kevinstyra@users.noreply.github.com>
`os.Exit` immediately exits the program and doesn't run defer functions.
This can be problematic as any command.OnFinalize routines and any logic
after the command.Execute won't be run.
Also suppress all RunE cobra error and usage messages. These would be
printed twice otherwise.
Signed-off-by: Stephan Renatus <stephan@styra.com>
Co-authored-by: Kevin St. Pierre <kevin@styra.com>
This allows certain plugins to do their cleanup routines -- like sending
decision logs to some other location when using a custom decision log
setup.
Signed-off-by: Stephan Renatus <stephan@styra.com>
And update code to conform to the rule.
- Replace unnecessary fmt.Sprintf with string concatenation
- Replace fmt.Sprint with more efficient strconv.Itoa
- Replace static fmt.Errorf calls with more efficient errors.New
Thanks @srenatus for pushing me down this rabbit hole!
Signed-off-by: Anders Eknert <anders@styra.com>
To make OPA behave as v0.x post v1.0 release.
If used simultaneously with `--v1-compatible` flag, the `--v0-compatible` flag takes precedence.
Also, future-proofing `cmd` package tests for 1.0.
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
* docs: Use Example field for alternative commands
This makes it safer to process this text into markdown and other
formats. (<path> is tricky as it looks like an HTML tag.
Signed-off-by: Charlie Egan <charlie@styra.com>
* docs: update CLI docs
Signed-off-by: Charlie Egan <charlie@styra.com>
---------
Signed-off-by: Charlie Egan <charlie@styra.com>
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>
In addition to those commands already supported:
* build
* check
* eval
* fmt
* test
support has been added to the following commands:
* `bench`
* `deps`
* `exec`
* `inspect`
* `parse`
* `run` (command `server` and `REPL`)
Fixes: #6520
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
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>
The incoming relative path is now converted as follows:
1. filepath.Abs: foo/bar -> c:\a\b\c\foo\bar
2. filepath.ToShasl: c:\a\b\c\foo\bar -> c:/a/b/c/foo/bar
3. prepend `file://`
That's something the runtime can make sense of, and the smoke test passes.
Fixes#5134.
Includes:
* ci: add smoke test with a bundle
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
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>
This is just a skeleton but the basic functionality is there: run OPA
in a "one shot" mode against a set of input files and print the
results for each.
Fixes#3525
Signed-off-by: Torin Sandall <torinsandall@gmail.com>