download

package
v0.63.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 28 Imported by: 14

Documentation

Overview

Package download implements low-level OPA bundle downloading.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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

func (c *Config) ValidateAndInjectDefaults() error

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 added in v0.19.0

func (d *Downloader) ClearCache()

ClearCache is deprecated. Use SetCache instead.

func (*Downloader) SetCache added in v0.30.0

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 added in v0.32.0

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) WithBundleName added in v0.42.0

func (d *Downloader) WithBundleName(bundleName string) *Downloader

WithBundleName specifies the name of the downloaded bundle.

func (*Downloader) WithBundleParserOpts added in v0.61.0

func (d *Downloader) WithBundleParserOpts(opts ast.ParserOptions) *Downloader

WithBundleParserOpts specifies the parser options to use when parsing downloaded bundles.

func (*Downloader) WithBundlePersistence added in v0.29.0

func (d *Downloader) WithBundlePersistence(persist bool) *Downloader

WithBundlePersistence specifies if the downloaded bundle will eventually be persisted to disk.

func (*Downloader) WithBundleVerificationConfig added in v0.22.0

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) WithLazyLoadingMode added in v0.42.0

func (d *Downloader) WithLazyLoadingMode(yes bool) *Downloader

WithLazyLoadingMode specifies how the downloaded bundle should be read. If true, data files in the bundle will not be deserialized and the check to validate that the bundle data does not contain paths outside the bundle's roots will not be performed while reading the bundle.

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 added in v0.25.0

func (d *Downloader) WithSizeLimitBytes(n int64) *Downloader

WithSizeLimitBytes sets the file size limit for bundles read by this downloader.

type HTTPError added in v0.38.0

type HTTPError struct {
	StatusCode int
}

func (HTTPError) Error added in v0.38.0

func (e HTTPError) Error() string

type OCIDownloader added in v0.40.0

type OCIDownloader struct {
	// contains filtered or unexported fields
}

func NewOCI added in v0.40.0

func NewOCI(config Config, client rest.Client, path, storePath string) *OCIDownloader

NewOCI returns a new Downloader that can be started.

func (*OCIDownloader) ClearCache added in v0.40.0

func (d *OCIDownloader) ClearCache()

ClearCache is deprecated. Use SetCache instead.

func (*OCIDownloader) SetCache added in v0.40.0

func (d *OCIDownloader) SetCache(etag string)

SetCache sets the etag value to the SHA of the loaded bundle

func (*OCIDownloader) Start added in v0.40.0

func (d *OCIDownloader) Start(ctx context.Context)

Start tells the Downloader to begin downloading bundles.

func (*OCIDownloader) Stop added in v0.40.0

func (d *OCIDownloader) Stop(context.Context)

Stop tells the Downloader to stop downloading bundles.

func (*OCIDownloader) Trigger added in v0.40.0

func (d *OCIDownloader) 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 (*OCIDownloader) WithBundleParserOpts added in v0.61.0

func (d *OCIDownloader) WithBundleParserOpts(opts ast.ParserOptions) *OCIDownloader

WithBundleParserOpts specifies the parser options to use when parsing downloaded bundles.

func (*OCIDownloader) WithBundlePersistence added in v0.40.0

func (d *OCIDownloader) WithBundlePersistence(persist bool) *OCIDownloader

WithBundlePersistence specifies if the downloaded bundle will eventually be persisted to disk.

func (*OCIDownloader) WithBundleVerificationConfig added in v0.40.0

func (d *OCIDownloader) WithBundleVerificationConfig(config *bundle.VerificationConfig) *OCIDownloader

WithBundleVerificationConfig sets the key configuration used to verify a signed bundle

func (*OCIDownloader) WithCallback added in v0.40.0

func (d *OCIDownloader) WithCallback(f func(context.Context, Update)) *OCIDownloader

WithCallback registers a function f to be called when download updates occur.

func (*OCIDownloader) WithLogAttrs added in v0.40.0

func (d *OCIDownloader) WithLogAttrs(attrs map[string]interface{}) *OCIDownloader

WithLogAttrs sets an optional set of key/value pair attributes to include in log messages emitted by the downloader.

func (*OCIDownloader) WithSizeLimitBytes added in v0.40.0

func (d *OCIDownloader) WithSizeLimitBytes(n int64) *OCIDownloader

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
	Size    int
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL