Commit Graph

15 Commits

Author SHA1 Message Date
Guangming Wang 952437ebe3 cleanup: fix some typos in code comment
Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
2019-08-21 09:24:37 -04:00
Torin Sandall 7a4e82194a bundle: Add support for scoping bundle to subset of data
Previously, when OPA activated a bundle, it would erase ALL existing
policy and data that had been cached. This meant that the bundles and
components like kube-mgmt were mutually exclusive (because the
bundles would overwrite the other component's policy and data.)

With these changes, bundles can include a set of roots that scope the
bundle. When the bundle activates, only policy and data under those
roots are erased and overwitten.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2019-02-19 10:51:19 -08:00
Ashutosh Narkar 7525de0be3 Add manifest metadata to bundle data (#1079)
Fixes #1062

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2018-11-26 11:04:09 -08:00
Torin Sandall c5171ed506 Add extra helpers to loader result
This avoids the usual boilerplate of working with the loader results.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2018-09-27 15:02:47 -07:00
Torin Sandall 0c66566673 Add support for command line bundle loading
Previously OPA would only load JSON/YAML/Rego files off the command
line. With these changes, OPA will load .tar.gz files and interpret them
as bundles. This is useful if you want to test your bundles locally with
OPA without running OPA as a server, configuring it to pull down the
bundle, etc.

Also, update docs to mention that data files MUST be named data.json.

Fixes #870
Fixes #873

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2018-08-08 16:10:34 -07:00
Stephan Renatus fd938f0661 Remove dead code
I don't know why I ended up looking into this, but I've run

    golangci-lint run --disable-all -E deadcode

on the code base and removed everything that came up :)

Signed-off-by: Stephan Renatus <srenatus@chef.io>
2018-07-02 09:19:15 -07:00
Torin Sandall be255c768e Add filtering to loader
These changes add filtering support to the loader. Users of the loader
package can provide a function that will filter the files included in
the loader.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2018-06-22 14:22:14 -07:00
Torin Sandall 942e870048 Refactor file loading to remove duplication
The file loader logic was unnecessarily duplicated across the top-level
file case and the recursive file case. These changes refactor the
implementation so that the logic is in one place and the file walker has
access to the depth which could be used in the future to place a limit
on recursion depth.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2018-06-22 14:22:14 -07:00
Stephan Renatus 2f1526c672 fix misspell
Signed-off-by: Stephan Renatus <srenatus@chef.io>
2018-06-05 09:50:13 -07:00
Torin Sandall b4c94fc108 Fix check subcommand parse error printing
The check subcommand was not formatting parse errors as JSON if
requested. Also, since the loader package returns a set of errors, parse
errors are unpacked to avoid double nesting.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
2018-04-09 09:51:00 -07:00
Torin Sandall f131cfcff3 Add support for bundle downloading
Previously, policies and data had to be pushed into OPA via the REST API
or loaded via command line arguments at startup.

With these changes, OPA can now be configured to pull down bundles of
policy and data from remote HTTP servers. When a bundle is downloaded
successfully, the policies and data are loaded out of the bundle file
and inserted into storage.
2018-03-16 08:51:37 -07:00
Torin Sandall 39f7b45fb7 Update directory loading convention
Previously, the loader would use directory names as top-level keys when
paths referred to directories. This meant that identical queries against
policies/data in differently named directories would return different
answers.

Now, the loader ignores the first directory name when recursing on
paths. Unfortunately this is not backwards compatible. Scripts and
workflows can be adapted as follows:

Before: opa test *
After:  opa test .

Before: opa test /some/path/to/dir/*
After:  opa test /some/path/to/dir

The same goes for opa run.
2018-03-12 18:14:32 -07:00
Torin Sandall c62d8129fb Expose path cleanup helper in loader pkg 2017-09-29 10:02:13 -07:00
Torin Sandall 9d21c8d564 Refactor loader to read inputs once
Previously, the loader would read the input file for each guess. For
non-file inputs (e.g., process substitution) this would fail. Now you
can pipe command output into OPA over the command line!

$ opa run <(echo '{"foo":"bar"}') -e 'data.foo'
"bar"
2017-09-12 12:19:53 -07:00
Torin Sandall c612260af4 Refactor file loading for OPA
The file loading logic implemented in the runtime package is generally
useful within OPA. These changes factor the file loading into a separate
package that can be reused without taking a dependency on the runtime.
2017-09-07 11:40:22 -07:00