cache

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 14 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 cnab.OCIReference) (bun CachedBundle, found bool, err error)
	StoreBundle(bundleRef cnab.BundleReference) (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(ref cnab.OCIReference) (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(bundleRef cnab.BundleReference) (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 {

	// BundleReference contains common bundle metadata, such as the definition.
	cnab.BundleReference

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

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

	// 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) BuildMetadataPath added in v1.0.1

func (cb *CachedBundle) BuildMetadataPath() string

BuildMetadataPath generates the location of the cache metadata.

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 *portercontext.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 Metadata added in v1.0.1

type Metadata struct {
	Reference cnab.OCIReference `json:"reference"`
	Digest    digest.Digest     `json:"digest"`
}

Metadata associated with a cached bundle.

type TestCache

type TestCache struct {
	FindBundleMock  func(ref cnab.OCIReference) (CachedBundle, bool, error)
	StoreBundleMock func(bundleReference cnab.BundleReference) (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(ref cnab.OCIReference) (CachedBundle, bool, error)

func (*TestCache) GetCacheDir

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

func (*TestCache) StoreBundle

func (c *TestCache) StoreBundle(bundleRef cnab.BundleReference) (CachedBundle, error)

Jump to

Keyboard shortcuts

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