repository

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: Apache-2.0 Imports: 18 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.
	Checksum string

	*sync.RWMutex
}

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, opts []getter.Option) (*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) 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) 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) StrategicallyLoadIndex

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

StrategicallyLoadIndex lazy-loads the Index from CachePath using LoadFromCache 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.

Jump to

Keyboard shortcuts

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