repository

package
v0.29.9 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeURL

func NormalizeURL(repositoryURL string) (string, error)

NormalizeURL normalizes a ChartRepository URL by its scheme.

func ValidateDepURL

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 Downloader

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) 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 OCIChartRepository

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

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

func (r *OCIChartRepository) Clear() error

Clear deletes the OCI registry credentials file.

func (*OCIChartRepository) DownloadChart

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

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

func (r *OCIChartRepository) HasCredentials() bool

HasCredentials returns true if the OCIChartRepository has credentials.

func (*OCIChartRepository) Login

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

func (r *OCIChartRepository) Logout() error

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

func (*OCIChartRepository) VerifyChart

func (r *OCIChartRepository) VerifyChart(ctx context.Context, chart *repo.ChartVersion) error

VerifyChart verifies the chart against a signature. If no signature is provided, a keyless verification is performed. It returns an error on failure.

type OCIChartRepositoryOption

type OCIChartRepositoryOption func(*OCIChartRepository) error

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

func WithCredentialsFile

func WithCredentialsFile(credentialsFile string) OCIChartRepositoryOption

WithCredentialsFile returns a ChartRepositoryOption that will set the credentials file

func WithOCIGetter

func WithOCIGetter(providers getter.Providers) OCIChartRepositoryOption

WithOCIGetter returns a ChartRepositoryOption that will set the getter.Getter

func WithOCIGetterOptions

func WithOCIGetterOptions(getterOpts []getter.Option) OCIChartRepositoryOption

WithOCIGetterOptions returns a ChartRepositoryOption that will set the getter.Options

func WithOCIRegistryClient

func WithOCIRegistryClient(client RegistryClient) OCIChartRepositoryOption

WithOCIRegistryClient returns a ChartRepositoryOption that will set the registry client

type RegistryClient

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