10 Commits

Author SHA1 Message Date
Stephan Renatus b15601876e go: cleanup old build flags
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2026-02-12 08:42:05 +01:00
Johan Fylling a179a24c48 v1 API
All packages, except for `cmd` and `internal`, have been moved into a new `v1` root package.

Old packages are kept for backwards-compatibility reasons. All contained code is replaced with simple type aliases and proxy functions to `v1` implementations.

Old packages default to the Rego v0 syntax, new `v1` packages default to the Rego v1 syntax.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2024-12-12 15:27:34 +01:00
Johan Fylling 7bb6dbe36b Preparing for v1 API
Moving (most) source to v1 root package to prepare for v0/v1 API separation.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2024-12-12 15:09:03 +01:00
Tyler Schade f37b5ccbc2 cmd+bundle: Add --follow-symlinks flag to include symlinked files when building bundles (#6800)
Signed-off-by: Tyler Schade <tyler.schade@solo.io>
2024-07-02 15:10:18 +02:00
Anders Eknert c0589c1272 Don't load files in tarball exceeding size_limit_bytes
Previously we'd check the size limit *after* the file was read, which
mostly defeats the point of the limit. Now we check the size from the
header in the tar archive and exit early if it exceeds the configured
limit.

In order to do this, I had to extend the `DirectoryLoader` interface
with a method to set the max size. While I added implementations for
the other (than tarball) loader types, the limit is not currently set
anywhere for those. Perhaps we'll want to do that at some later point
but it feels like this is mainly relevant when files are loaded via
remote bundles.

Fixes #6514

Signed-off-by: Anders Eknert <anders@styra.com>
2024-01-18 09:14:16 -08:00
Anton Gubarev 9c9b27376a make func newDescriptor and withCloser public
Signed-off-by: Anton Gubarev <antgubarev.dev@gmail.com>
2024-01-11 23:55:35 -08:00
Kieran Othen b65c68e340 Add ability to load bundles from an arbitrary filesystem
Support OPA Client SDK programs loading bundles from an arbitraty filesystem, such as an in-memory filesystem, which unlocks additional uses that include compiling a bundle to an intermediate representation from a client program rather than the OPA command line.

Fixes #5833

bundle: Add filesystem support
Soften constraint in `Equal` method to support bundle comparison for rootless filesystems, eg treat "/file" and "file" as equal for both URLs and Paths
Add `WithPathFormat` for `DirectoryLoader` builders to centralise logic for how paths are returned during file traversal, ie in `NextFile`
Add support for specifiying the root directory for `dirLoaderFS`

compile: Add filesystem support
Add `WithFS` builder helper to pass into `initload.LoadPaths` to load bundles from a filesystem

internal/runtime/init: Add filesystem support
Pass newly supplied `fsys fs.FS` parameter in `LoadPaths` into file loader builder

loader: Add filesystem support
Add new `GetBundleDirectLoaderFS` which can load bundles from the supplied filesystem

runtime: Add filesystem support
Pass-through nil parameter as `fsys fs.FS` parameter into `initLoad.LoadPaths` (OPA servers/repls are not in scope for loading from filesystem)

util/test: Add in-memory filesystem support
Add new `WithTestFS` helper to allow tests that currently use `WithTempFS` to choose between a disk-based or memory-based filesystem - now used throughout `compile_test`

Signed-off-by: Kieran Othen <kieran.othen@mac.com>
2023-04-26 12:28:17 -07:00
Ashutosh Narkar 1841703e77 opa build: fix bundle mode to work with ignore flag (#5044)
Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
2022-08-31 07:18:16 +02:00
Shuhei Kitagawa 06664d0f02 ci: Update golangci-lint to v1.43.0 (#4173)
Signed-off-by: shuheiktgw <s-kitagawa@mercari.com>
2021-12-28 08:43:28 +01:00
Simon Gottschlag 32ee3b77b6 bundle: Implement a DirectoryLoader for fs.FS (#3493)
To make it possible to create a DirectoryLoader based on the fs.FS interface.
This interface requires go version 1.16 or above.

Fixes: #3489

Signed-off-by: Simon Gottschlag <simon.gottschlag@xenit.se>
2021-05-31 10:18:45 +02:00