bundle

package
v0.35.1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const DriverName = "bundle"

Variables

View Source
var ErrBundleNotLoaded = errors.New("bundle not loaded yet")
View Source
var ErrNoSource = errors.New("at least one of local or remote sources must be defined")

Functions

func NewStore

func NewStore(ctx context.Context, conf *Conf) (storage.BinaryStore, error)

Types

type Bundle

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

func Open

func Open(opts OpenOpts) (*Bundle, error)

func (*Bundle) Close added in v0.30.0

func (b *Bundle) Close() error

func (*Bundle) GetFirstMatch added in v0.29.0

func (b *Bundle) GetFirstMatch(_ context.Context, candidates []namer.ModuleID) (*runtimev1.RunnablePolicySet, error)

func (*Bundle) InspectPolicies added in v0.35.0

func (*Bundle) ListPolicyIDs

func (b *Bundle) ListPolicyIDs(_ context.Context, _ storage.ListPolicyIDsParams) ([]string, error)

func (*Bundle) ListSchemaIDs

func (b *Bundle) ListSchemaIDs(_ context.Context) ([]string, error)

func (*Bundle) LoadSchema

func (b *Bundle) LoadSchema(_ context.Context, path string) (io.ReadCloser, error)

func (*Bundle) Release

func (b *Bundle) Release() error

type CloudAPIClient

type CloudAPIClient interface {
	BootstrapBundle(context.Context, string) (string, error)
	GetBundle(context.Context, string) (string, error)
	WatchBundle(context.Context, string) (cloudapi.WatchHandle, error)
	GetCachedBundle(string) (string, error)
}

type Conf

type Conf struct {
	// Remote holds configuration for remote bundle source. Takes precedence over local if both are defined.
	Remote *RemoteSourceConf `yaml:"remote"`
	// Local holds configuration for local bundle source.
	Local *LocalSourceConf `yaml:"local"`
	// Credentials holds bundle source credentials.
	Credentials *hub.CredentialsConf `yaml:"credentials" conf:",ignore"`
	// CacheSize defines the number of policies to cache in memory.
	CacheSize uint `yaml:"cacheSize" conf:",example=1024"`
}

Conf is required (if driver is set to 'bundle') configuration for bundle storage driver. +desc=This section is required only if storage.driver is bundle.

func GetConf

func GetConf() (*Conf, error)

func (*Conf) Key

func (conf *Conf) Key() string

func (*Conf) SetDefaults

func (conf *Conf) SetDefaults()

func (*Conf) Validate

func (conf *Conf) Validate() (outErr error)

type HybridStore

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

func (*HybridStore) Close added in v0.30.0

func (hs *HybridStore) Close() (outErr error)

func (*HybridStore) Driver

func (*HybridStore) Driver() string

func (*HybridStore) GetFirstMatch added in v0.29.0

func (hs *HybridStore) GetFirstMatch(ctx context.Context, candidates []namer.ModuleID) (*runtimev1.RunnablePolicySet, error)

func (*HybridStore) InspectPolicies added in v0.35.0

func (*HybridStore) ListPolicyIDs

func (hs *HybridStore) ListPolicyIDs(ctx context.Context, params storage.ListPolicyIDsParams) ([]string, error)

func (*HybridStore) ListSchemaIDs

func (hs *HybridStore) ListSchemaIDs(ctx context.Context) ([]string, error)

func (*HybridStore) LoadSchema

func (hs *HybridStore) LoadSchema(ctx context.Context, id string) (io.ReadCloser, error)

func (*HybridStore) SourceKind added in v0.27.0

func (hs *HybridStore) SourceKind() string

type LocalParams

type LocalParams struct {
	BundlePath string
	TempDir    string
	SecretKey  string
	CacheSize  uint
}

type LocalSource

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

LocalSource loads a bundle from local disk.

func NewLocalSource

func NewLocalSource(params LocalParams) (*LocalSource, error)

func NewLocalSourceFromConf

func NewLocalSourceFromConf(_ context.Context, conf *Conf) (*LocalSource, error)

func (*LocalSource) Close

func (ls *LocalSource) Close() error

func (*LocalSource) Driver

func (ls *LocalSource) Driver() string

func (*LocalSource) GetFirstMatch added in v0.29.0

func (ls *LocalSource) GetFirstMatch(ctx context.Context, candidates []namer.ModuleID) (ps *runtimev1.RunnablePolicySet, err error)

func (*LocalSource) InspectPolicies added in v0.35.0

func (*LocalSource) ListPolicyIDs

func (ls *LocalSource) ListPolicyIDs(ctx context.Context, params storage.ListPolicyIDsParams) (ids []string, err error)

func (*LocalSource) ListSchemaIDs

func (ls *LocalSource) ListSchemaIDs(ctx context.Context) (ids []string, err error)

func (*LocalSource) LoadSchema

func (ls *LocalSource) LoadSchema(ctx context.Context, id string) (schema io.ReadCloser, err error)

func (*LocalSource) Reload

func (ls *LocalSource) Reload(_ context.Context) error

func (*LocalSource) SourceKind added in v0.27.0

func (ls *LocalSource) SourceKind() string

type LocalSourceConf

type LocalSourceConf struct {
	// BundlePath is the full path to the local bundle file.
	BundlePath string `yaml:"bundlePath" conf:"required,example=/path/to/bundle.crbp"`
	// TempDir is the directory to use for temporary files.
	TempDir string `yaml:"tempDir" conf:",example=${TEMP}"`
}

LocalSourceConf holds configuration for local bundle store.

type OpenOpts

type OpenOpts struct {
	Credentials *credentials.Credentials
	ScratchFS   afero.Fs
	BundlePath  string
	Source      string
	CacheSize   uint
}

type RemoteSource

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

RemoteSource implements a bundle store that loads bundles from a remote source.

func NewRemoteSource

func NewRemoteSource(conf *Conf) (*RemoteSource, error)

func (*RemoteSource) Close added in v0.30.0

func (s *RemoteSource) Close() error

func (*RemoteSource) Driver

func (s *RemoteSource) Driver() string

func (*RemoteSource) GetFirstMatch added in v0.29.0

func (s *RemoteSource) GetFirstMatch(ctx context.Context, candidates []namer.ModuleID) (*runtimev1.RunnablePolicySet, error)

func (*RemoteSource) Init

func (s *RemoteSource) Init(ctx context.Context) error

func (*RemoteSource) InitWithClient

func (s *RemoteSource) InitWithClient(ctx context.Context, client CloudAPIClient) error

func (*RemoteSource) InspectPolicies added in v0.35.0

func (*RemoteSource) IsHealthy

func (s *RemoteSource) IsHealthy() bool

func (*RemoteSource) ListPolicyIDs

func (s *RemoteSource) ListPolicyIDs(ctx context.Context, params storage.ListPolicyIDsParams) ([]string, error)

func (*RemoteSource) ListSchemaIDs

func (s *RemoteSource) ListSchemaIDs(ctx context.Context) ([]string, error)

func (*RemoteSource) LoadSchema

func (s *RemoteSource) LoadSchema(ctx context.Context, id string) (io.ReadCloser, error)

func (*RemoteSource) Reload

func (s *RemoteSource) Reload(ctx context.Context) error

func (*RemoteSource) SourceKind added in v0.27.0

func (s *RemoteSource) SourceKind() string

type RemoteSourceConf

type RemoteSourceConf struct {
	// Connection defines settings for the remote server connection.
	Connection *hub.ConnectionConf `yaml:"connection" conf:",ignore"`
	// BundleLabel to fetch from the server.
	BundleLabel string `yaml:"bundleLabel" conf:"required,example=latest"`
	// CacheDir is the directory to use for caching downloaded bundles.
	CacheDir string `yaml:"cacheDir" conf:",example=${XDG_CACHE_DIR}"`
	// TempDir is the directory to use for temporary files.
	TempDir string `yaml:"tempDir" conf:",example=${TEMP}"`
	// DisableAutoUpdate sets whether new bundles should be automatically downloaded and applied.
	DisableAutoUpdate bool `yaml:"disableAutoUpdate"`
}

RemoteSourceConf holds configuration for remote bundle store.

type Source added in v0.27.0

type Source interface {
	SourceKind() string
}

Jump to

Keyboard shortcuts

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