package download
import "github.com/open-policy-agent/opa/download"
Package download implements low-level OPA bundle downloading.
Index ¶
- type Config
- type Downloader
- func New(config Config, client rest.Client, path string) *Downloader
- func (d *Downloader) ClearCache()
- func (d *Downloader) SetCache(etag string)
- func (d *Downloader) Start(ctx context.Context)
- func (d *Downloader) Stop(context.Context)
- func (d *Downloader) Trigger(ctx context.Context) error
- func (d *Downloader) WithBundlePersistence(persist bool) *Downloader
- func (d *Downloader) WithBundleVerificationConfig(config *bundle.VerificationConfig) *Downloader
- func (d *Downloader) WithCallback(f func(context.Context, Update)) *Downloader
- func (d *Downloader) WithLogAttrs(attrs map[string]interface{}) *Downloader
- func (d *Downloader) WithSizeLimitBytes(n int64) *Downloader
- type PollingConfig
- type Update
Types ¶
type Config ¶
type Config struct { Trigger *plugins.TriggerMode `json:"trigger,omitempty"` Polling PollingConfig `json:"polling"` }
Config represents the configuration for the downloader.
func (*Config) ValidateAndInjectDefaults ¶
ValidateAndInjectDefaults checks for configuration errors and ensures all values are set on the Config object.
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
Downloader implements low-level OPA bundle downloading. Downloader can be started and stopped. After starting, the downloader will request bundle updates from the remote HTTP endpoint that the client is configured to connect to.
func New ¶
func New(config Config, client rest.Client, path string) *Downloader
New returns a new Downloader that can be started.
func (*Downloader) ClearCache ¶
func (d *Downloader) ClearCache()
ClearCache is deprecated. Use SetCache instead.
func (*Downloader) SetCache ¶
func (d *Downloader) SetCache(etag string)
SetCache sets the given etag value on the downloader.
func (*Downloader) Start ¶
func (d *Downloader) Start(ctx context.Context)
Start tells the Downloader to begin downloading bundles.
func (*Downloader) Stop ¶
func (d *Downloader) Stop(context.Context)
Stop tells the Downloader to stop downloading bundles.
func (*Downloader) Trigger ¶
func (d *Downloader) Trigger(ctx context.Context) error
Trigger can be used to control when the downloader attempts to download a new bundle in manual triggering mode.
func (*Downloader) WithBundlePersistence ¶
func (d *Downloader) WithBundlePersistence(persist bool) *Downloader
WithBundlePersistence specifies if the downloaded bundle will eventually be persisted to disk.
func (*Downloader) WithBundleVerificationConfig ¶
func (d *Downloader) WithBundleVerificationConfig(config *bundle.VerificationConfig) *Downloader
WithBundleVerificationConfig sets the key configuration used to verify a signed bundle
func (*Downloader) WithCallback ¶
func (d *Downloader) WithCallback(f func(context.Context, Update)) *Downloader
WithCallback registers a function f to be called when download updates occur.
func (*Downloader) WithLogAttrs ¶
func (d *Downloader) WithLogAttrs(attrs map[string]interface{}) *Downloader
WithLogAttrs sets an optional set of key/value pair attributes to include in log messages emitted by the downloader.
func (*Downloader) WithSizeLimitBytes ¶
func (d *Downloader) WithSizeLimitBytes(n int64) *Downloader
WithSizeLimitBytes sets the file size limit for bundles read by this downloader.
type PollingConfig ¶
type PollingConfig struct { MinDelaySeconds *int64 `json:"min_delay_seconds,omitempty"` // min amount of time to wait between successful poll attempts MaxDelaySeconds *int64 `json:"max_delay_seconds,omitempty"` // max amount of time to wait between poll attempts LongPollingTimeoutSeconds *int64 `json:"long_polling_timeout_seconds,omitempty"` // max amount of time the server should wait before issuing a timeout if there's no update available }
PollingConfig represents polling configuration for the downloader.
type Update ¶
type Update struct { ETag string Bundle *bundle.Bundle Error error Metrics metrics.Metrics Raw io.Reader }
Update contains the result of a download. If an error occurred, the Error field will be non-nil. If a new bundle is available, the Bundle field will be non-nil.
Source Files ¶
- Version
- v0.34.2
- Published
- Nov 10, 2021
- Platform
- darwin/amd64
- Imports
- 17 packages
- Last checked
- 26 minutes ago –
Tools for package owners.