extractor

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidBundleData = errors.New("invalid bundle data")
View Source
var ErrInvalidIndexData = errors.New("invalid index data")
View Source
var ErrTaglessImage = errors.New("indexImage is tagless, skipping the addon as it is not onboarded")

Functions

This section is empty.

Types

type BundleCache

type BundleCache interface {
	// GetBundle returns a bundle for the given image. An error is
	// returned if the bundle cannot be retrieved or the data is
	// corrupted.
	GetBundle(img string) (*operator.Bundle, error)
	// SetBundle caches a bundle for the given image. An error
	// is returned if the bundle cannot be cached.
	SetBundle(img string, bundle operator.Bundle) error
}

BundleCache provides a cache of OPM bundles which are referenced by bundleImage name.

type BundleCacheImpl added in v0.15.0

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

func NewBundleCacheImpl added in v0.15.0

func NewBundleCacheImpl(opts ...BundleCacheImplOption) *BundleCacheImpl

NewBundleCacheImpl returns an initialized BundleCacheImpl. A variadic slice of options can be used to alter the behavior of the cache.

func (*BundleCacheImpl) GetBundle added in v0.15.0

func (c *BundleCacheImpl) GetBundle(img string) (*operator.Bundle, error)

func (*BundleCacheImpl) SetBundle added in v0.15.0

func (c *BundleCacheImpl) SetBundle(img string, bundle operator.Bundle) error

type BundleCacheImplConfig added in v0.15.0

type BundleCacheImplConfig struct {
	Store Store
}

func (*BundleCacheImplConfig) Default added in v0.15.0

func (c *BundleCacheImplConfig) Default()

func (*BundleCacheImplConfig) Option added in v0.15.0

func (c *BundleCacheImplConfig) Option(opts ...BundleCacheImplOption)

type BundleCacheImplOption added in v0.15.0

type BundleCacheImplOption interface {
	ConfigureBundleCacheImpl(*BundleCacheImplConfig)
}

type BundleExtractor

type BundleExtractor interface {
	Extract(ctx context.Context, bundleImage string) (operator.Bundle, error)
}

BundleExtractor - extracts a single bundle from it's bundleImage, using the bundle format by OPM. Bundle format: https://docs.openshift.com/container-platform/4.9/operators/understanding/olm-packaging-format.html#olm-bundle-format_olm-packaging-format

type BundleExtractorOpt

type BundleExtractorOpt func(e *DefaultBundleExtractor)

func WithBundleCache

func WithBundleCache(cache BundleCache) BundleExtractorOpt

func WithBundleLog

func WithBundleLog(log logrus.FieldLogger) BundleExtractorOpt

func WithBundleTimeout

func WithBundleTimeout(timeout time.Duration) BundleExtractorOpt

type DefaultBundleExtractor

type DefaultBundleExtractor struct {
	Log     logrus.FieldLogger
	Cache   BundleCache
	Timeout time.Duration
}

func NewBundleExtractor

func NewBundleExtractor(opts ...BundleExtractorOpt) *DefaultBundleExtractor

func (*DefaultBundleExtractor) Extract

func (e *DefaultBundleExtractor) Extract(ctx context.Context, bundleImage string) (operator.Bundle, error)

func (*DefaultBundleExtractor) ValidateBundle added in v0.10.0

func (e *DefaultBundleExtractor) ValidateBundle(ctx context.Context, registry *containerdregistry.Registry, tmpDir string) error

type DefaultIndexExtractor

type DefaultIndexExtractor struct {
	Log   logrus.FieldLogger
	Cache IndexCache
}

func NewIndexExtractor

func NewIndexExtractor(opts ...IndexExtractorOpt) *DefaultIndexExtractor

NewIndexExtractor - takes a variadic slice of options to configure an index extractor and applies defaults if no appropriate option is given.

func (*DefaultIndexExtractor) ExtractAllBundleImages

func (e *DefaultIndexExtractor) ExtractAllBundleImages(ctx context.Context, indexImage string) ([]string, error)

ExtractAllBundleImages - returns a sorted list of all bundles for all pkgs

func (*DefaultIndexExtractor) ExtractBundleImages

func (e *DefaultIndexExtractor) ExtractBundleImages(ctx context.Context, indexImage string, pkgName string) ([]string, error)

ExtractBundleImages - returns a sorted list of bundles for a given pkg

type Extractor

type Extractor interface {
	// extract all bundles from indexImage matching pkgName
	ExtractBundles(ctx context.Context, indexImage string, pkgName string) ([]operator.Bundle, error)
	// extract all bundles from indexImage, for all packages
	ExtractAllBundles(ctx context.Context, indexImage string) ([]operator.Bundle, error)
}

Extractor - utilizes both the indexExtractor and bundleExtractor to first extract all bundleImages from an indexImage, and then extract all the corresponding bundles from those underlying bundleImages.

type IndexCache

type IndexCache interface {
	// GetBundleImages retrieves bundles image names for a particular
	// indexImage and package combination.
	GetBundleImages(indexImage string, pkgName string) ([]string, error)
	// SetBundleImages stores a map from package name to bundle images
	// for a particular indexImage. An error is returned if the data
	// cannot be written.
	SetBundleImages(indexImage string, bundleImagesMap map[string][]string) error
}

IndexCache provides a cache of index images which store related bundles by package name.

type IndexCacheImpl added in v0.15.0

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

func NewIndexCacheImpl added in v0.15.0

func NewIndexCacheImpl(opts ...IndexCacheImplOption) *IndexCacheImpl

NewIndexCacheImpl returns an initialized IndexImage cache which stores the package names and related bundle images for an IndexImage. A variadic slice of options may be provided to alter the cache behavior.

func (*IndexCacheImpl) GetBundleImages added in v0.15.0

func (c *IndexCacheImpl) GetBundleImages(indexImage string, cacheKey string) ([]string, error)

func (*IndexCacheImpl) SetBundleImages added in v0.15.0

func (c *IndexCacheImpl) SetBundleImages(indexImage string, pkgBundlesMap map[string][]string) error

type IndexCacheImplConfig added in v0.15.0

type IndexCacheImplConfig struct {
	Store Store
}

func (*IndexCacheImplConfig) Default added in v0.15.0

func (c *IndexCacheImplConfig) Default()

func (*IndexCacheImplConfig) Option added in v0.15.0

func (c *IndexCacheImplConfig) Option(opts ...IndexCacheImplOption)

type IndexCacheImplOption added in v0.15.0

type IndexCacheImplOption interface {
	ConfigureIndexCacheImpl(*IndexCacheImplConfig)
}

type IndexExtractor

type IndexExtractor interface {
	// extract all bundleImages contained in indexImage, matching pkgName
	ExtractBundleImages(ctx context.Context, indexImage string, pkgName string) ([]string, error)
	// extract all bundleImages contained in the indexImage, for all packages.
	ExtractAllBundleImages(ctx context.Context, indexImage string) ([]string, error)
}

IndexExtractor - extracts bundleImages from an indexImage. Supports both the sql and file based catalog format. An indexImage contains one or multiple packages, which contain bundleImages. Catalog format: https://docs.openshift.com/container-platform/4.9/operators/admin/olm-managing-custom-catalogs.html#olm-managing-custom-catalogs-fb

type IndexExtractorOpt

type IndexExtractorOpt func(e *DefaultIndexExtractor)

func WithIndexCache

func WithIndexCache(cache IndexCache) IndexExtractorOpt

func WithIndexLog

func WithIndexLog(log logrus.FieldLogger) IndexExtractorOpt

type MainExtractor

type MainExtractor struct {
	Log    logrus.FieldLogger
	Index  IndexExtractor
	Bundle BundleExtractor
}

func New

func New(opts ...MainExtractorOpt) *MainExtractor

New - creates a new mainExtractor, with the provided options. Order of provided options matter, as the logger descends into both the bundle and index extractors.

func (*MainExtractor) ApplyDefaults

func (e *MainExtractor) ApplyDefaults()

func (*MainExtractor) ExtractAllBundles

func (e *MainExtractor) ExtractAllBundles(ctx context.Context, indexImage string) ([]operator.Bundle, error)

ExtractAllBundles - extract bundles for all packages from indexImage

func (*MainExtractor) ExtractBundles

func (e *MainExtractor) ExtractBundles(ctx context.Context, indexImage string, pkgName string) ([]operator.Bundle, error)

ExtractBundles - extract bundles from indexImage matching pkgName

type MainExtractorOpt

type MainExtractorOpt func(e *MainExtractor)

func WithBundleExtractor

func WithBundleExtractor(bundleExtractor BundleExtractor) MainExtractorOpt

func WithIndexExtractor

func WithIndexExtractor(indexExtractor IndexExtractor) MainExtractorOpt

func WithLog

func WithLog(log logrus.FieldLogger) MainExtractorOpt

type Store added in v0.15.0

type Store interface {
	// Read retrieves data with a given id. 'ok'
	// returns false if the id does not exist.
	Read(id interface{}) (data interface{}, ok bool)
	// Write sets the given data for the given id.
	// An error should be returned if the data
	// could not be applied successfully.
	Write(id, data interface{}) error
}

Store provides object storage for arbitrary keys.

type ThreadSafeStore added in v0.15.0

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

func NewThreadSafeStore added in v0.15.0

func NewThreadSafeStore() *ThreadSafeStore

NewThreadSafeStore returns an implementation of the 'Store' interface which is safe for concurrent use by multiple goroutines.

func (*ThreadSafeStore) Read added in v0.15.0

func (s *ThreadSafeStore) Read(id interface{}) (interface{}, bool)

func (*ThreadSafeStore) Write added in v0.15.0

func (s *ThreadSafeStore) Write(id, data interface{}) error

type WithStore added in v0.15.0

type WithStore struct{ Store }

WithStore provides the given Store implementation to cache implementation for object storage.

func (WithStore) ConfigureBundleCacheImpl added in v0.15.0

func (w WithStore) ConfigureBundleCacheImpl(c *BundleCacheImplConfig)

func (WithStore) ConfigureIndexCacheImpl added in v0.15.0

func (w WithStore) ConfigureIndexCacheImpl(c *IndexCacheImplConfig)

Jump to

Keyboard shortcuts

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