mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
feat(download): add opa_no_oci flag to build without containerd
Signed-off-by: slonka <slonka@users.noreply.github.com>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
//go:build !opa_no_oci
|
||||
|
||||
package download
|
||||
|
||||
import (
|
||||
@@ -11,7 +13,6 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
@@ -30,25 +31,6 @@ import (
|
||||
"github.com/open-policy-agent/opa/util"
|
||||
)
|
||||
|
||||
type OCIDownloader struct {
|
||||
config Config // downloader configuration for tuning polling and other downloader behaviour
|
||||
client rest.Client // HTTP client to use for bundle downloading
|
||||
path string // path for OCI image as <registry>/<org>/<repo>:<tag>
|
||||
localStorePath string // path for the local OCI storage
|
||||
trigger chan chan struct{} // channel to signal downloads when manual triggering is enabled
|
||||
stop chan chan struct{} // used to signal plugin to stop running
|
||||
f func(context.Context, Update) // callback function invoked when download updates occur
|
||||
sizeLimitBytes *int64 // max bundle file size in bytes (passed to reader)
|
||||
bvc *bundle.VerificationConfig
|
||||
wg sync.WaitGroup
|
||||
logger logging.Logger
|
||||
mtx sync.Mutex
|
||||
stopped bool
|
||||
persist bool
|
||||
store *oci.Store
|
||||
etag string
|
||||
}
|
||||
|
||||
// NewOCI returns a new Downloader that can be started.
|
||||
func NewOCI(config Config, client rest.Client, path, storePath string) *OCIDownloader {
|
||||
localstore, err := oci.New(storePath)
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
//go:build opa_no_oci
|
||||
|
||||
package download
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/open-policy-agent/opa/bundle"
|
||||
"github.com/open-policy-agent/opa/plugins/rest"
|
||||
)
|
||||
|
||||
func NewOCI(Config, rest.Client, string, string) *OCIDownloader {
|
||||
panic("built without OCI support")
|
||||
}
|
||||
|
||||
func (d *OCIDownloader) WithCallback(f func(context.Context, Update)) *OCIDownloader {
|
||||
panic("built without OCI support")
|
||||
}
|
||||
|
||||
func (d *OCIDownloader) WithLogAttrs(map[string]interface{}) *OCIDownloader {
|
||||
panic("built without OCI support")
|
||||
}
|
||||
|
||||
func (d *OCIDownloader) WithBundleVerificationConfig(*bundle.VerificationConfig) *OCIDownloader {
|
||||
panic("built without OCI support")
|
||||
}
|
||||
|
||||
func (d *OCIDownloader) WithSizeLimitBytes(int64) *OCIDownloader {
|
||||
panic("built without OCI support")
|
||||
}
|
||||
|
||||
func (d *OCIDownloader) WithBundlePersistence(bool) *OCIDownloader {
|
||||
panic("built without OCI support")
|
||||
}
|
||||
|
||||
func (d *OCIDownloader) ClearCache() {
|
||||
panic("built without OCI support")
|
||||
}
|
||||
|
||||
func (d *OCIDownloader) SetCache(string) {
|
||||
panic("built without OCI support")
|
||||
}
|
||||
|
||||
func (d *OCIDownloader) Trigger(context.Context) error {
|
||||
panic("built without OCI support")
|
||||
}
|
||||
|
||||
func (d *OCIDownloader) Start(context.Context) {
|
||||
panic("built without OCI support")
|
||||
}
|
||||
|
||||
func (d *OCIDownloader) Stop(context.Context) {
|
||||
panic("built without OCI support")
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package download
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/open-policy-agent/opa/bundle"
|
||||
"github.com/open-policy-agent/opa/logging"
|
||||
"github.com/open-policy-agent/opa/plugins/rest"
|
||||
"oras.land/oras-go/v2/content/oci"
|
||||
)
|
||||
|
||||
type OCIDownloader struct {
|
||||
config Config // downloader configuration for tuning polling and other downloader behaviour
|
||||
client rest.Client // HTTP client to use for bundle downloading
|
||||
path string // path for OCI image as <registry>/<org>/<repo>:<tag>
|
||||
localStorePath string // path for the local OCI storage
|
||||
trigger chan chan struct{} // channel to signal downloads when manual triggering is enabled
|
||||
stop chan chan struct{} // used to signal plugin to stop running
|
||||
f func(context.Context, Update) // callback function invoked when download updates occur
|
||||
sizeLimitBytes *int64 // max bundle file size in bytes (passed to reader)
|
||||
bvc *bundle.VerificationConfig
|
||||
wg sync.WaitGroup
|
||||
logger logging.Logger
|
||||
mtx sync.Mutex
|
||||
stopped bool
|
||||
persist bool
|
||||
store *oci.Store
|
||||
etag string
|
||||
}
|
||||
Reference in New Issue
Block a user