repository

package
v0.24.4 Latest Latest
Warning

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

Go to latest
Published: May 3, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoChartIndex = errors.New("no chart index")

Functions

func NormalizeURL

func NormalizeURL(url string) string

NormalizeURL normalizes a ChartRepository URL by ensuring it ends with a single "/".

Types

type ChartRepository

type ChartRepository struct {
	// URL the ChartRepository's index.yaml can be found at,
	// without the index.yaml suffix.
	URL string
	// Client to use while downloading the Index or a chart from the URL.
	Client getter.Getter
	// Options to configure the Client with while downloading the Index
	// or a chart from the URL.
	Options []getter.Option
	// CachePath is the path of a cached index.yaml for read-only operations.
	CachePath string
	// Cached indicates if the ChartRepository index.yaml has been cached
	// to CachePath.
	Cached bool
	// Index contains a loaded chart repository index if not nil.
	Index *repo.IndexFile
	// Checksum contains the SHA256 checksum of the loaded chart repository
	// index bytes. This is different from the checksum of the CachePath, which
	// may contain unordered entries.
	Checksum string

	*sync.RWMutex
	// contains filtered or unexported fields
}

ChartRepository represents a Helm chart repository, and the configuration required to download the chart index and charts from the repository. All methods are thread safe unless defined otherwise.

func NewChartRepository

func NewChartRepository(repositoryURL, cachePath string, providers getter.Providers, tlsConfig *tls.Config, getterOpts []getter.Option, chartRepoOpts ...ChartRepositoryOption) (*ChartRepository, error)

NewChartRepository constructs and returns a new ChartRepository with the ChartRepository.Client configured to the getter.Getter for the repository URL scheme. It returns an error on URL parsing failures, or if there is no getter available for the scheme.

func (*ChartRepository) CacheIndex

func (r *ChartRepository) CacheIndex() (string, error)

CacheIndex attempts to write the index from the remote into a new temporary file using DownloadIndex, and sets CachePath and Cached. It returns the SHA256 checksum of the downloaded index bytes, or an error. The caller is expected to handle the garbage collection of CachePath, and to load the Index separately using LoadFromCache if required.

func (*ChartRepository) CacheIndexInMemory added in v0.24.0

func (r *ChartRepository) CacheIndexInMemory() error

CacheIndexInMemory attempts to cache the index in memory. It returns an error if it fails. The cache key have to be safe in multi-tenancy environments, as otherwise it could be used as a vector to bypass the helm repository's authentication.

func (*ChartRepository) DownloadChart

func (r *ChartRepository) DownloadChart(chart *repo.ChartVersion) (*bytes.Buffer, error)

DownloadChart confirms the given repo.ChartVersion has a downloadable URL, and then attempts to download the chart using the Client and Options of the ChartRepository. It returns a bytes.Buffer containing the chart data.

func (*ChartRepository) DownloadIndex

func (r *ChartRepository) DownloadIndex(w io.Writer) (err error)

DownloadIndex attempts to download the chart repository index using the Client and set Options, and writes the index to the given io.Writer. It returns an url.Error if the URL failed to parse.

func (*ChartRepository) Get

func (r *ChartRepository) Get(name, ver string) (*repo.ChartVersion, error)

Get returns the repo.ChartVersion for the given name, the version is expected to be a semver.Constraints compatible string. If version is empty, the latest stable version will be returned and prerelease versions will be ignored.

func (*ChartRepository) HasCacheFile

func (r *ChartRepository) HasCacheFile() bool

HasCacheFile returns true if CachePath is not empty.

func (*ChartRepository) HasIndex

func (r *ChartRepository) HasIndex() bool

HasIndex returns true if the Index is not nil.

func (*ChartRepository) LoadFromCache

func (r *ChartRepository) LoadFromCache() error

LoadFromCache attempts to load the Index from the configured CachePath. It returns an error if no CachePath is set, or if the load failed.

func (*ChartRepository) LoadFromFile

func (r *ChartRepository) LoadFromFile(path string) error

LoadFromFile reads the file at the given path and loads it into Index.

func (*ChartRepository) LoadFromMemCache added in v0.24.0

func (r *ChartRepository) LoadFromMemCache() bool

LoadFromMemCache attempts to load the Index from the provided cache. It returns true if the Index was found in the cache, and false otherwise.

func (*ChartRepository) LoadIndexFromBytes

func (r *ChartRepository) LoadIndexFromBytes(b []byte) error

LoadIndexFromBytes loads Index from the given bytes. It returns a repo.ErrNoAPIVersion error if the API version is not set

func (*ChartRepository) RemoveCache

func (r *ChartRepository) RemoveCache() error

RemoveCache removes the CachePath if Cached.

func (*ChartRepository) SetMemCache added in v0.24.0

func (r *ChartRepository) SetMemCache(key string, c *cache.Cache, ttl time.Duration, rec RecordMetricsFunc)

SetMemCache sets the cache to use for this repository.

func (*ChartRepository) StrategicallyLoadIndex

func (r *ChartRepository) StrategicallyLoadIndex() (err error)

StrategicallyLoadIndex lazy-loads the Index first from Indexcache, then from CachePath using oadFromCache if it does not HasIndex. If not HasCacheFile, a cache attempt is made using CacheIndex before continuing to load.

func (*ChartRepository) Unload

func (r *ChartRepository) Unload()

Unload can be used to signal the Go garbage collector the Index can be freed from memory if the ChartRepository object is expected to continue to exist in the stack for some time.

type ChartRepositoryOption added in v0.24.0

type ChartRepositoryOption func(*ChartRepository) error

ChartRepositoryOption is a function that can be passed to NewChartRepository to configure a ChartRepository.

func WithMemoryCache added in v0.24.0

func WithMemoryCache(key string, c *cache.Cache, ttl time.Duration, rec RecordMetricsFunc) ChartRepositoryOption

WithMemoryCache returns a ChartRepositoryOptions that will enable the ChartRepository to cache the index.yaml file in memory. The cache key have to be safe in multi-tenancy environments, as otherwise it could be used as a vector to bypass the helm repository's authentication.

type RecordMetricsFunc added in v0.24.0

type RecordMetricsFunc func(event string)

RecordMetricsFunc is a function that records metrics.

Jump to

Keyboard shortcuts

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