opa: github.com/open-policy-agent/opa/download Index | Files

package download

import "github.com/open-policy-agent/opa/download"

Package download implements low-level OPA bundle downloading.


Package Files

config.go download.go

type Config Uses

type Config struct {
    Polling PollingConfig `json:"polling"`

Config represents the configuration for the downloader.

func (*Config) ValidateAndInjectDefaults Uses

func (c *Config) ValidateAndInjectDefaults() error

ValidateAndInjectDefaults checks for configuration errors and ensures all values are set on the Config object.

type Downloader Uses

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 Uses

func New(config Config, client rest.Client, path string) *Downloader

New returns a new Downloader that can be started.

func (*Downloader) Start Uses

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

Start tells the Downloader to begin downloading bundles.

func (*Downloader) Stop Uses

func (d *Downloader) Stop(ctx context.Context)

Stop tells the Downloader to stop begin downloading bundles.

func (*Downloader) WithCallback Uses

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 Uses

func (d *Downloader) WithLogAttrs(attrs [][2]string) *Downloader

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

type PollingConfig Uses

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

PollingConfig represents polling configuration for the downloader.

type Update Uses

type Update struct {
    ETag    string
    Bundle  *bundle.Bundle
    Error   error
    Metrics metrics.Metrics

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.

Package download imports 11 packages (graph) and is imported by 4 packages. Updated 2020-02-13. Refresh now. Tools for package owners.