|
|
|
@ -196,33 +196,65 @@ func (r *ChartRepository) generateIndex() error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FindChartInRepoURL finds chart in chart repository pointed by repoURL
|
|
|
|
|
// without adding repo to repositories
|
|
|
|
|
func FindChartInRepoURL(repoURL, chartName, chartVersion, certFile, keyFile, caFile string, getters getter.Providers) (string, error) {
|
|
|
|
|
return FindChartInAuthRepoURL(repoURL, "", "", chartName, chartVersion, certFile, keyFile, caFile, getters)
|
|
|
|
|
type findChartInRepoURLOptions struct {
|
|
|
|
|
Username string
|
|
|
|
|
Password string
|
|
|
|
|
PassCredentialsAll bool
|
|
|
|
|
InsecureSkipTLSverify bool
|
|
|
|
|
CertFile string
|
|
|
|
|
KeyFile string
|
|
|
|
|
CAFile string
|
|
|
|
|
ChartVersion string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type FindChartInRepoURLOption func(*findChartInRepoURLOptions)
|
|
|
|
|
|
|
|
|
|
// WithChartVersion specifies the chart version to find
|
|
|
|
|
func WithChartVersion(chartVersion string) FindChartInRepoURLOption {
|
|
|
|
|
return func(options *findChartInRepoURLOptions) {
|
|
|
|
|
options.ChartVersion = chartVersion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// WithUsernamePassword specifies the username/password credntials for the repository
|
|
|
|
|
func WithUsernamePassword(username, password string) FindChartInRepoURLOption {
|
|
|
|
|
return func(options *findChartInRepoURLOptions) {
|
|
|
|
|
options.Username = username
|
|
|
|
|
options.Password = password
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FindChartInAuthRepoURL finds chart in chart repository pointed by repoURL
|
|
|
|
|
// without adding repo to repositories, like FindChartInRepoURL,
|
|
|
|
|
// but it also receives credentials for the chart repository.
|
|
|
|
|
func FindChartInAuthRepoURL(repoURL, username, password, chartName, chartVersion, certFile, keyFile, caFile string, getters getter.Providers) (string, error) {
|
|
|
|
|
return FindChartInAuthAndTLSRepoURL(repoURL, username, password, chartName, chartVersion, certFile, keyFile, caFile, false, getters)
|
|
|
|
|
// WithPassCredentialsAll flags whether credentials should be passed on to other domains
|
|
|
|
|
func WithPassCredentialsAll(passCredentialsAll bool) FindChartInRepoURLOption {
|
|
|
|
|
return func(options *findChartInRepoURLOptions) {
|
|
|
|
|
options.PassCredentialsAll = passCredentialsAll
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FindChartInAuthAndTLSRepoURL finds chart in chart repository pointed by repoURL
|
|
|
|
|
// without adding repo to repositories, like FindChartInRepoURL,
|
|
|
|
|
// but it also receives credentials and TLS verify flag for the chart repository.
|
|
|
|
|
// TODO Helm 4, FindChartInAuthAndTLSRepoURL should be integrated into FindChartInAuthRepoURL.
|
|
|
|
|
func FindChartInAuthAndTLSRepoURL(repoURL, username, password, chartName, chartVersion, certFile, keyFile, caFile string, insecureSkipTLSverify bool, getters getter.Providers) (string, error) {
|
|
|
|
|
return FindChartInAuthAndTLSAndPassRepoURL(repoURL, username, password, chartName, chartVersion, certFile, keyFile, caFile, insecureSkipTLSverify, false, getters)
|
|
|
|
|
// WithClientTLS species the cert, key, and CA files for client mTLS
|
|
|
|
|
func WithClientTLS(certFile, keyFile, caFile string) FindChartInRepoURLOption {
|
|
|
|
|
return func(options *findChartInRepoURLOptions) {
|
|
|
|
|
options.CertFile = certFile
|
|
|
|
|
options.KeyFile = keyFile
|
|
|
|
|
options.CAFile = caFile
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// WithInsecureSkipTLSverify skips TLS verification for repostory communication
|
|
|
|
|
func WithInsecureSkipTLSverify(insecureSkipTLSverify bool) FindChartInRepoURLOption {
|
|
|
|
|
return func(options *findChartInRepoURLOptions) {
|
|
|
|
|
options.InsecureSkipTLSverify = insecureSkipTLSverify
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FindChartInAuthAndTLSAndPassRepoURL finds chart in chart repository pointed by repoURL
|
|
|
|
|
// without adding repo to repositories, like FindChartInRepoURL,
|
|
|
|
|
// but it also receives credentials, TLS verify flag, and if credentials should
|
|
|
|
|
// be passed on to other domains.
|
|
|
|
|
// TODO Helm 4, FindChartInAuthAndTLSAndPassRepoURL should be integrated into FindChartInAuthRepoURL.
|
|
|
|
|
func FindChartInAuthAndTLSAndPassRepoURL(repoURL, username, password, chartName, chartVersion, certFile, keyFile, caFile string, insecureSkipTLSverify, passCredentialsAll bool, getters getter.Providers) (string, error) {
|
|
|
|
|
// FindChartInRepoURL finds chart in chart repository pointed by repoURL
|
|
|
|
|
// without adding repo to repositories
|
|
|
|
|
func FindChartInRepoURL(repoURL string, chartName string, getters getter.Providers, options ...FindChartInRepoURLOption) (string, error) {
|
|
|
|
|
|
|
|
|
|
opts := findChartInRepoURLOptions{}
|
|
|
|
|
for _, option := range options {
|
|
|
|
|
option(&opts)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Download and write the index file to a temporary location
|
|
|
|
|
buf := make([]byte, 20)
|
|
|
|
@ -231,14 +263,14 @@ func FindChartInAuthAndTLSAndPassRepoURL(repoURL, username, password, chartName,
|
|
|
|
|
|
|
|
|
|
c := Entry{
|
|
|
|
|
URL: repoURL,
|
|
|
|
|
Username: username,
|
|
|
|
|
Password: password,
|
|
|
|
|
PassCredentialsAll: passCredentialsAll,
|
|
|
|
|
CertFile: certFile,
|
|
|
|
|
KeyFile: keyFile,
|
|
|
|
|
CAFile: caFile,
|
|
|
|
|
Username: opts.Username,
|
|
|
|
|
Password: opts.Password,
|
|
|
|
|
PassCredentialsAll: opts.PassCredentialsAll,
|
|
|
|
|
CertFile: opts.CertFile,
|
|
|
|
|
KeyFile: opts.KeyFile,
|
|
|
|
|
CAFile: opts.CAFile,
|
|
|
|
|
Name: name,
|
|
|
|
|
InsecureSkipTLSverify: insecureSkipTLSverify,
|
|
|
|
|
InsecureSkipTLSverify: opts.InsecureSkipTLSverify,
|
|
|
|
|
}
|
|
|
|
|
r, err := NewChartRepository(&c, getters)
|
|
|
|
|
if err != nil {
|
|
|
|
@ -260,10 +292,10 @@ func FindChartInAuthAndTLSAndPassRepoURL(repoURL, username, password, chartName,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
errMsg := fmt.Sprintf("chart %q", chartName)
|
|
|
|
|
if chartVersion != "" {
|
|
|
|
|
errMsg = fmt.Sprintf("%s version %q", errMsg, chartVersion)
|
|
|
|
|
if opts.ChartVersion != "" {
|
|
|
|
|
errMsg = fmt.Sprintf("%s version %q", errMsg, opts.ChartVersion)
|
|
|
|
|
}
|
|
|
|
|
cv, err := repoIndex.Get(chartName, chartVersion)
|
|
|
|
|
cv, err := repoIndex.Get(chartName, opts.ChartVersion)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", errors.Errorf("%s not found in %s repository", errMsg, repoURL)
|
|
|
|
|
}
|
|
|
|
|