store

package
v0.0.0-...-c87bc11 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultStoreDir

func DefaultStoreDir() (string, error)

DefaultStoreDir returns the default location for the store. It's dependent on operating system:

- Windows: %LocalAppData%\kubebuilder-envtest - OSX: ~/Library/Application Support/io.kubebuilder.envtest - Others: ${XDG_DATA_HOME:-~/.local/share}/kubebuilder-envtest

Otherwise, it errors out. Note that these paths must not be relied upon manually.

Types

type Filter

type Filter struct {
	Version  versions.Spec
	Platform versions.Platform
}

Filter is a version spec & platform selector (i.e. platform potentially with wilcards) to filter store items.

func (Filter) Matches

func (f Filter) Matches(item Item) bool

Matches checks if this filter matches the given item.

type Item

type Item struct {
	Version  versions.Concrete
	Platform versions.Platform
}

Item is a version-platform pair.

func (Item) String

func (i Item) String() string

type Store

type Store struct {
	// Root is the root FS that the store stores in.  You'll probably
	// want to use a BasePathFS to scope it down to a particular directory.
	//
	// Note that if for some reason there are nested BasePathFSes, and they're
	// interrupted by a non-BasePathFS, Path won't work properly.
	Root afero.Fs
}

Store knows how to list, load, store, and delete envtest tools.

func NewAt

func NewAt(path string) *Store

NewAt creates a new store on disk at the given path.

func (*Store) Add

func (s *Store) Add(ctx context.Context, item Item, contents io.Reader) (resErr error)

Add adds this item to the store, with the given contents (a .tar.gz file).

func (*Store) Has

func (s *Store) Has(item Item) (bool, error)

Has checks if an item exists in the store.

func (*Store) Initialize

func (s *Store) Initialize(ctx context.Context) error

Initialize ensures that the store is all set up on disk, etc.

func (*Store) List

func (s *Store) List(ctx context.Context, matching Filter) ([]Item, error)

List lists all items matching the given filter.

Results are stored by version (newest first), and OS/arch (consistently, but no guaranteed ordering).

func (*Store) Path

func (s *Store) Path(item Item) (string, error)

Path returns an actual path that case be used to access this item.

func (*Store) Remove

func (s *Store) Remove(ctx context.Context, matching Filter) ([]Item, error)

Remove removes all items matching the given filter.

It returns a list of the successfully removed items (even in the case of an error).

Jump to

Keyboard shortcuts

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