cache

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2020 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BundleCache

type BundleCache interface {
	FindBundle(tag string) (bun CachedBundle, found bool, err error)
	StoreBundle(tag string, bun bundle.Bundle, reloMap *relocation.ImageRelocationMap) (CachedBundle, error)
	GetCacheDir() (string, error)
}

func New

func New(cfg *config.Config) BundleCache

type Cache

type Cache struct {
	*config.Config
}

func (*Cache) FindBundle

func (c *Cache) FindBundle(bundleTag string) (CachedBundle, bool, error)

FindBundle looks for a given bundle tag in the Porter bundle cache and returns the path to the bundle if it exists. If it is not found, an empty string and the boolean false value are returned. If the bundle is found, and a relocation mapping file is present, it will be returned as well. If the relocation is not found, an empty string is returned.

func (*Cache) GetCacheDir

func (c *Cache) GetCacheDir() (string, error)

func (*Cache) StoreBundle

func (c *Cache) StoreBundle(bundleTag string, bun bundle.Bundle, reloMap *relocation.ImageRelocationMap) (CachedBundle, error)

StoreBundle will write a given bundle to the bundle cache, in a location derived from the bundleTag. If a relocation mapping is provided, it will be stored along side the bundle. If successful, returns the path to the bundle, along with the path to a relocation mapping, if provided. Otherwise, returns an error.

type CachedBundle

type CachedBundle struct {

	// Tag of the cached bundle.
	Tag string

	// Bundle is the cached bundle definition.
	Bundle bundle.Bundle

	// BundlePath is the location of the bundle.json in the cache.
	BundlePath string

	// Manifest is the optional porter.yaml manifest. This is only populated
	// when the bundle was a porter built bundle that had a manifest embedded in
	// the custom metadata.
	Manifest *manifest.Manifest

	// ManifestPath is the optional location of the porter.yaml in the cache.
	ManifestPath string

	// RelocationMap is the optional relocation map enclosed in the bundle.
	RelocationMap *relocation.ImageRelocationMap

	// RelocationFilePath is the optional location of the relocation file in the cache.
	RelocationFilePath string
	// contains filtered or unexported fields
}

CachedBundle represents a bundle pulled from a registry that has been cached to the filesystem.

func (*CachedBundle) BuildBundlePath

func (cb *CachedBundle) BuildBundlePath() string

BuildBundlePath generates the potential location of the bundle.json, if it existed.

func (*CachedBundle) BuildManifestPath

func (cb *CachedBundle) BuildManifestPath() string

BuildManifestPath generates the potential location of the manifest, if it existed.

func (*CachedBundle) BuildRelocationFilePath

func (cb *CachedBundle) BuildRelocationFilePath() string

BuildRelocationFilePath generates the potential location of the relocation file, if it existed.

func (*CachedBundle) GetBundleID

func (cb *CachedBundle) GetBundleID() string

GetBundleID is the unique ID of the cached bundle.

func (*CachedBundle) Load

func (cb *CachedBundle) Load(cxt *context.Context) (bool, error)

Load starts from the bundle tag, and hydrates the cached bundle from the cache.

func (*CachedBundle) SetCacheDir

func (cb *CachedBundle) SetCacheDir(porterCacheDir string)

SetCacheDir sets the bundle specific cache directory based on the given Porter cache directory.

type TestCache

type TestCache struct {
	FindBundleMock  func(string) (CachedBundle, bool, error)
	StoreBundleMock func(string, bundle.Bundle, *relocation.ImageRelocationMap) (CachedBundle, error)
	// contains filtered or unexported fields
}

MockCache helps you test error scenarios, you don't need it for unit testing positive scenarios.

func NewTestCache

func NewTestCache(cache BundleCache) *TestCache

func (*TestCache) FindBundle

func (c *TestCache) FindBundle(tag string) (CachedBundle, bool, error)

func (*TestCache) GetCacheDir

func (c *TestCache) GetCacheDir() (string, error)

func (*TestCache) StoreBundle

func (c *TestCache) StoreBundle(tag string, bun bundle.Bundle, reloMap *relocation.ImageRelocationMap) (CachedBundle, error)

Jump to

Keyboard shortcuts

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