cache

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Put(ctx context.Context, helmRepoNamespace, helmRepoName string, value Data) error
	Delete(ctx context.Context, helmRepoNamespace, helmRepoName string) error
	// ListProfiles specifically retrieve profiles data only to avoid traversing the values structure for no reason.
	ListProfiles(ctx context.Context, helmRepoNamespace, helmRepoName string) ([]*pb.Profile, error)
	// GetProfileValues will try and find a specific values file for the given profileName and profileVersion. Returns an
	// error if said version is not found.
	GetProfileValues(ctx context.Context, helmRepoNamespace, helmRepoName, profileName, profileVersion string) ([]byte, error)
	// ListAvailableVersionsForProfile returns all stored available versions for a profile.
	ListAvailableVersionsForProfile(ctx context.Context, helmRepoNamespace, helmRepoName, profileName string) ([]string, error)
}

Cache defines an interface to work with the profile data cacher.

type Data

type Data struct {
	Profiles []*pb.Profile `yaml:"profiles"`
	Values   ValueMap
}

Data is explicit data for a specific profile including values. Saved as `profiles.yaml` and `profileName/version/values.yaml`.

type ProfileCache

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

ProfileCache is used to cache profiles data from scanner helm repositories.

func NewCache

func NewCache(cacheLocation string) (*ProfileCache, error)

NewCache initialises the cache and returns it.

func (*ProfileCache) Delete

func (c *ProfileCache) Delete(ctx context.Context, helmRepoNamespace, helmRepoName string) error

Delete clears the cache folder for a specific HelmRepository. It will only clear the innermost folder so others in the same namespace may retain their values.

func (*ProfileCache) GetProfileValues

func (c *ProfileCache) GetProfileValues(ctx context.Context, helmRepoNamespace, helmRepoName, profileName, profileVersion string) ([]byte, error)

GetProfileValues returns the content of the cached values file if it exists. Errors otherwise.

func (*ProfileCache) ListAvailableVersionsForProfile added in v0.7.0

func (c *ProfileCache) ListAvailableVersionsForProfile(ctx context.Context, helmRepoNamespace, helmRepoName, profileName string) ([]string, error)

ListAvailableVersionsForProfile returns all stored available versions for a profile.

func (*ProfileCache) ListProfiles

func (c *ProfileCache) ListProfiles(ctx context.Context, helmRepoNamespace, helmRepoName string) ([]*pb.Profile, error)

ListProfiles gathers all profiles for a helmRepo if found. Returns an error otherwise.

func (*ProfileCache) Put

func (c *ProfileCache) Put(ctx context.Context, helmRepoNamespace, helmRepoName string, value Data) error

Put adds a new entry or updates an existing entry in the cache for the helmRepository.

type ValueMap

type ValueMap map[profileName]map[profileVersion][]byte

ValueMap contains easy access for a profile name and version based values file.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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