freezer

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 14 Imported by: 2

README

Freezer: A Library to Help Keep Your Buildpacks on Ice

Usage

func TestIntegration(t *testing.T) {
	fetcher := freezer.NewFetcher()
	Expect(fetcher.Open()).To(Succeed())
	defer fetcher.Close()

	localBuildpack, err = fetcher.Get("path/to/buildpack", freezer.Uncached)
	Expect(err).NotTo(HaveOccurred())

	localBuildpackCached, err = fetcher.Get("path/to/buildpack", freezer.Cached)
	Expect(err).NotTo(HaveOccurred())

	remoteBuildpack, err = fetcher.Get("github.com/remote/buildpack", freezer.Uncached)
	Expect(err).NotTo(HaveOccurred())

	remoteBuildpackCached, err = fetcher.Get("github.com/remote/buildpack", freezer.Cached)
	Expect(err).NotTo(HaveOccurred())
}

Cleaning Up Cache Corruption

If there is any cache corruption you can go to $HOME/.freezer-cache and either delete all of the contents or find the offending file and delete that. Local buildpacks are under their name and if you have a cached version it will be in a sub directory named cached, if you are dealing with a remote buildpack it will be under in a directory that is the org you pulled it from then in a directory that is the name of the repo and if you have a cached version it will be in a sub directory named cached. If you delete any of these files they will be rebuilt or fetched on your next run.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildpackCache

type BuildpackCache interface {
	Get(key string) (CacheEntry, bool, error)
	Set(key string, cachedEntry CacheEntry) error
	Dir() string
}

type CacheDB

type CacheDB map[string]CacheEntry

type CacheEntry

type CacheEntry struct {
	Version string
	URI     string
}

type CacheManager

type CacheManager struct {
	Cache CacheDB
	// contains filtered or unexported fields
}

func NewCacheManager

func NewCacheManager(cacheDir string) CacheManager

func (CacheManager) Close

func (c CacheManager) Close() error

func (CacheManager) Dir

func (c CacheManager) Dir() string

func (CacheManager) Get

func (c CacheManager) Get(key string) (CacheEntry, bool, error)

This function exists for two reasons one is so that is could have a standard getter setter interface and the setter is a more complex function the other is to allow for table locking if this were to be adapted for parallel package management

func (*CacheManager) Open

func (c *CacheManager) Open() error

func (*CacheManager) Set

func (c *CacheManager) Set(key string, value CacheEntry) error

type Executable added in v0.0.4

type Executable interface {
	Execute(pexec.Execution) error
}

type GitReleaseFetcher

type GitReleaseFetcher interface {
	Get(org, repo string) (github.Release, error)
	GetReleaseAsset(asset github.ReleaseAsset) (io.ReadCloser, error)
	GetReleaseTarball(url string) (io.ReadCloser, error)
}

type LocalBuildpack

type LocalBuildpack struct {
	Path        string
	Name        string
	UncachedKey string
	CachedKey   string
	Offline     bool
	Version     string
}

func NewLocalBuildpack

func NewLocalBuildpack(path, name string) LocalBuildpack

type LocalFetcher

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

func NewLocalFetcher

func NewLocalFetcher(buildpackCache BuildpackCache, packager Packager, namer Namer) LocalFetcher

func (LocalFetcher) Get

func (l LocalFetcher) Get(buildpack LocalBuildpack) (string, error)

func (LocalFetcher) WithPackager added in v0.0.8

func (l LocalFetcher) WithPackager(packager Packager) LocalFetcher

type NameGenerator

type NameGenerator struct{}

func NewNameGenerator

func NewNameGenerator() NameGenerator

func (NameGenerator) RandomName

func (n NameGenerator) RandomName(name string) (string, error)

type Namer

type Namer interface {
	RandomName(name string) (string, error)
}

type Packager

type Packager interface {
	Execute(buildpackDir, output, version string, cached bool) error
}

type PackingTools

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

func NewPackingTools

func NewPackingTools() PackingTools

func (PackingTools) Execute

func (p PackingTools) Execute(buildpackDir, output, version string, cached bool) error

func (PackingTools) WithExecutable added in v0.0.4

func (p PackingTools) WithExecutable(executable Executable) PackingTools

func (PackingTools) WithPack added in v0.1.0

func (p PackingTools) WithPack(pack Executable) PackingTools

func (PackingTools) WithTempOutput added in v0.1.0

func (p PackingTools) WithTempOutput(tempOutput func(string, string) (string, error)) PackingTools

type RemoteBuildpack

type RemoteBuildpack struct {
	Org         string
	Repo        string
	UncachedKey string
	CachedKey   string
	Offline     bool
	Version     string
}

func NewRemoteBuildpack

func NewRemoteBuildpack(org, repo string) RemoteBuildpack

type RemoteFetcher

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

func NewRemoteFetcher

func NewRemoteFetcher(buildpackCache BuildpackCache, gitReleaseFetcher GitReleaseFetcher, packager Packager) RemoteFetcher

func (RemoteFetcher) Get

func (r RemoteFetcher) Get(buildpack RemoteBuildpack) (string, error)

func (RemoteFetcher) WithFileSystem added in v0.1.0

func (r RemoteFetcher) WithFileSystem(fileSystem func(string, string) (string, error)) RemoteFetcher

func (RemoteFetcher) WithPackager added in v0.0.8

func (r RemoteFetcher) WithPackager(packager Packager) RemoteFetcher

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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