repository

package
v1.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func IndexFromBytes added in v0.35.0

func IndexFromBytes(b []byte) (*repo.IndexFile, error)

IndexFromBytes loads a repo.IndexFile from the given bytes. It returns an error if the bytes cannot be parsed, or if the API version is not set. The entries are sorted before the index is returned.

func IndexFromFile added in v0.35.0

func IndexFromFile(path string) (*repo.IndexFile, error)

IndexFromFile loads a repo.IndexFile from the given path. It returns an error if the file does not exist, is not a regular file, exceeds the maximum index file size, or if the file cannot be parsed.

func NormalizeURL

func NormalizeURL(repositoryURL string) (string, error)

NormalizeURL normalizes a ChartRepository URL by its scheme.

func ValidateDepURL added in v0.25.10

func ValidateDepURL(repositoryURL string) error

ValidateDepURL returns an error if the given depended repository URL declaration is not supported The reason for this is that the dependency manager will not be able to resolve the alias declaration e.g. repository: "@fantastic-charts"

Types

type ChartRepository

type ChartRepository struct {
	// URL the ChartRepository's index.yaml can be found at,
	// without the index.yaml suffix.
	URL string
	// Path is the absolute path to the Index file.
	Path string
	// Index of the ChartRepository.
	Index *repo.IndexFile

	// 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

	*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(URL, path string, providers getter.Providers, tlsConfig *tls.Config, getterOpts ...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() error

CacheIndex attempts to write the index from the remote into a new temporary file using DownloadIndex, and sets Path and cached. The caller is expected to handle the garbage collection of Path, and to load the Index separately using LoadFromPath if required.

func (*ChartRepository) Clear added in v0.26.0

func (r *ChartRepository) Clear() error

Clear clears the Index and removes the file at Path, if cached.

func (*ChartRepository) Digest added in v0.35.0

func (r *ChartRepository) Digest(algorithm digest.Algorithm) digest.Digest

Digest returns the digest of the file at the ChartRepository's Path.

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, maxSize int64) (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. Upon download, the index is copied to the writer if the index size does not exceed the maximum index file size. Otherwise, it returns an error. A url.Error is returned if the URL failed to parse.

func (*ChartRepository) GetChartVersion added in v0.26.0

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

GetChartVersion 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) HasFile added in v0.35.0

func (r *ChartRepository) HasFile() bool

HasFile returns true if Path exists and is a regular file.

func (*ChartRepository) HasIndex

func (r *ChartRepository) HasIndex() bool

HasIndex returns true if the Index is not nil.

func (*ChartRepository) Invalidate added in v0.35.0

func (r *ChartRepository) Invalidate()

Invalidate clears any cached digests.

func (*ChartRepository) LoadFromPath added in v0.35.0

func (r *ChartRepository) LoadFromPath() error

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

func (*ChartRepository) StrategicallyLoadIndex

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

StrategicallyLoadIndex lazy-loads the Index if required, first attempting to load it from Path if the file exists, before falling back to caching it.

func (*ChartRepository) ToJSON added in v1.1.0

func (r *ChartRepository) ToJSON() ([]byte, error)

ToJSON returns the index formatted as JSON.

func (*ChartRepository) VerifyChart added in v0.31.0

VerifyChart verifies the chart against a signature. It returns an error on failure.

type Downloader added in v0.26.0

type Downloader interface {
	// GetChartVersion returns the repo.ChartVersion for the given name and version
	// from the remote Helm repository or OCI Helm repository.
	GetChartVersion(name, version string) (*repo.ChartVersion, error)
	// DownloadChart downloads a chart from the remote Helm repository or OCI Helm repository.
	DownloadChart(chart *repo.ChartVersion) (*bytes.Buffer, error)
	// VerifyChart verifies the chart against a signature.
	VerifyChart(ctx context.Context, chart *repo.ChartVersion) (oci.VerificationResult, error)
	// Clear removes all temporary files created by the downloader, caching the files if the cache is configured,
	// and calling garbage collector to remove unused files.
	Clear() error
}

Downloader is used to download a chart from a remote Helm repository or OCI Helm repository.

type ErrExternal added in v0.33.0

type ErrExternal struct {
	Err error
}

ErrExternal is a generic error for errors related to external API calls.

func (*ErrExternal) Error added in v0.33.0

func (ee *ErrExternal) Error() string

Error implements the error interface.

func (*ErrExternal) Unwrap added in v0.33.0

func (ee *ErrExternal) Unwrap() error

Unwrap returns the underlying error.

type ErrReference added in v0.33.0

type ErrReference struct {
	Err error
}

ErrReference indicate invalid chart reference.

func (*ErrReference) Error added in v0.33.0

func (er *ErrReference) Error() string

Error implements the error interface.

func (*ErrReference) Unwrap added in v0.33.0

func (er *ErrReference) Unwrap() error

Unwrap returns the underlying error.

type OCIChartRepository added in v0.25.0

type OCIChartRepository struct {
	// URL is the location of the repository.
	URL url.URL
	// Client to use while accessing the repository's contents.
	Client getter.Getter
	// Options to configure the Client with while downloading tags
	// or a chart from the URL.
	Options []getter.Option

	// RegistryClient is a client to use while downloading tags or charts from a registry.
	RegistryClient RegistryClient
	// contains filtered or unexported fields
}

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

func NewOCIChartRepository added in v0.25.0

func NewOCIChartRepository(repositoryURL string, chartRepoOpts ...OCIChartRepositoryOption) (*OCIChartRepository, error)

NewOCIChartRepository 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. It assumes that the url scheme has been validated to be an OCI scheme.

func (*OCIChartRepository) Clear added in v0.26.0

func (r *OCIChartRepository) Clear() error

Clear deletes the OCI registry credentials file.

func (*OCIChartRepository) DownloadChart added in v0.25.0

func (r *OCIChartRepository) 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. In case of an OCI hosted chart, this function assumes that the chartVersion url is valid.

func (*OCIChartRepository) GetChartVersion added in v0.26.0

func (r *OCIChartRepository) GetChartVersion(name, ver string) (*repo.ChartVersion, error)

GetChartVersion 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. adapted from https://github.com/helm/helm/blob/49819b4ef782e80b0c7f78c30bd76b51ebb56dc8/pkg/downloader/chart_downloader.go#L162

func (*OCIChartRepository) HasCredentials added in v0.26.0

func (r *OCIChartRepository) HasCredentials() bool

HasCredentials returns true if the OCIChartRepository has credentials.

func (*OCIChartRepository) Login added in v0.25.0

func (r *OCIChartRepository) Login(opts ...registry.LoginOption) error

Login attempts to login to the OCI registry. It returns an error on failure.

func (*OCIChartRepository) Logout added in v0.25.0

func (r *OCIChartRepository) Logout() error

Logout attempts to logout from the OCI registry. It returns an error on failure.

func (*OCIChartRepository) VerifyChart added in v0.31.0

VerifyChart verifies the chart against a signature. Supports signature verification using either cosign or notation providers. If no signature is provided, when cosign is used, a keyless verification is performed. The verification result is returned as a VerificationResult and any error encountered.

type OCIChartRepositoryOption added in v0.25.0

type OCIChartRepositoryOption func(*OCIChartRepository) error

OCIChartRepositoryOption is a function that can be passed to NewOCIChartRepository to configure an OCIChartRepository.

func WithCertificatesStore added in v1.1.0

func WithCertificatesStore(store string) OCIChartRepositoryOption

WithCertificatesStore returns a ChartRepositoryOption that will set the certificates store

func WithCredentialsFile added in v0.26.0

func WithCredentialsFile(credentialsFile string) OCIChartRepositoryOption

WithCredentialsFile returns a ChartRepositoryOption that will set the credentials file

func WithInsecureHTTP added in v1.2.0

func WithInsecureHTTP() OCIChartRepositoryOption

func WithOCIGetter added in v0.25.0

func WithOCIGetter(providers getter.Providers) OCIChartRepositoryOption

WithOCIGetter returns a ChartRepositoryOption that will set the getter.Getter

func WithOCIGetterOptions added in v0.25.0

func WithOCIGetterOptions(getterOpts []getter.Option) OCIChartRepositoryOption

WithOCIGetterOptions returns a ChartRepositoryOption that will set the getter.Options

func WithOCIRegistryClient added in v0.25.0

func WithOCIRegistryClient(client RegistryClient) OCIChartRepositoryOption

WithOCIRegistryClient returns a ChartRepositoryOption that will set the registry client

func WithVerifiers added in v0.31.0

func WithVerifiers(verifiers []oci.Verifier) OCIChartRepositoryOption

WithVerifiers returns a ChartRepositoryOption that will set the chart verifiers

type RegistryClient added in v0.25.0

type RegistryClient interface {
	Login(host string, opts ...registry.LoginOption) error
	Logout(host string, opts ...registry.LogoutOption) error
	Tags(url string) ([]string, error)
}

RegistryClient is an interface for interacting with OCI registries It is used by the OCIChartRepository to retrieve chart versions from OCI registries

Jump to

Keyboard shortcuts

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