mirror of
https://github.com/helm/helm.git
synced 2026-08-08 09:01:25 +00:00
Add username/password to dependency build/update subcommands
Signed-off-by: Evans Mungai <mbuevans@gmail.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"helm.sh/helm/v3/cmd/helm/require"
|
||||
"helm.sh/helm/v3/pkg/action"
|
||||
@@ -120,3 +121,16 @@ func newDependencyListCmd(out io.Writer) *cobra.Command {
|
||||
f.UintVar(&client.ColumnWidth, "max-col-width", 80, "maximum column width for output table")
|
||||
return cmd
|
||||
}
|
||||
|
||||
func addDependencySubcommandFlags(f *pflag.FlagSet, client *action.Dependency) {
|
||||
f.BoolVar(&client.Verify, "verify", false, "verify the packages against signatures")
|
||||
f.StringVar(&client.Keyring, "keyring", defaultKeyring(), "keyring containing public keys")
|
||||
f.BoolVar(&client.SkipRefresh, "skip-refresh", false, "do not refresh the local repository cache")
|
||||
f.StringVar(&client.Username, "username", "", "chart repository username where to locate the requested chart")
|
||||
f.StringVar(&client.Password, "password", "", "chart repository password where to locate the requested chart")
|
||||
f.StringVar(&client.CertFile, "cert-file", "", "identify HTTPS client using this SSL certificate file")
|
||||
f.StringVar(&client.KeyFile, "key-file", "", "identify HTTPS client using this SSL key file")
|
||||
f.BoolVar(&client.InsecureSkipTLSverify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the chart download")
|
||||
f.BoolVar(&client.PlainHTTP, "plain-http", false, "use insecure HTTP connections for the chart download")
|
||||
f.StringVar(&client.CAFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle")
|
||||
}
|
||||
@@ -41,7 +41,7 @@ If no lock file is found, 'helm dependency build' will mirror the behavior
|
||||
of 'helm dependency update'.
|
||||
`
|
||||
|
||||
func newDependencyBuildCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
||||
func newDependencyBuildCmd(_ *action.Configuration, out io.Writer) *cobra.Command {
|
||||
client := action.NewDependency()
|
||||
|
||||
cmd := &cobra.Command{
|
||||
@@ -54,13 +54,19 @@ func newDependencyBuildCmd(cfg *action.Configuration, out io.Writer) *cobra.Comm
|
||||
if len(args) > 0 {
|
||||
chartpath = filepath.Clean(args[0])
|
||||
}
|
||||
registryClient, err := newRegistryClient(client.CertFile, client.KeyFile, client.CAFile,
|
||||
client.InsecureSkipTLSverify, client.PlainHTTP, client.Username, client.Password)
|
||||
if err != nil {
|
||||
return fmt.Errorf("missing registry client: %w", err)
|
||||
}
|
||||
|
||||
man := &downloader.Manager{
|
||||
Out: out,
|
||||
ChartPath: chartpath,
|
||||
Keyring: client.Keyring,
|
||||
SkipUpdate: client.SkipRefresh,
|
||||
Getters: getter.All(settings),
|
||||
RegistryClient: cfg.RegistryClient,
|
||||
RegistryClient: registryClient,
|
||||
RepositoryConfig: settings.RepositoryConfig,
|
||||
RepositoryCache: settings.RepositoryCache,
|
||||
Debug: settings.Debug,
|
||||
@@ -68,7 +74,7 @@ func newDependencyBuildCmd(cfg *action.Configuration, out io.Writer) *cobra.Comm
|
||||
if client.Verify {
|
||||
man.Verify = downloader.VerifyIfPossible
|
||||
}
|
||||
err := man.Build()
|
||||
err = man.Build()
|
||||
if e, ok := err.(downloader.ErrRepoNotFound); ok {
|
||||
return fmt.Errorf("%s. Please add the missing repos via 'helm repo add'", e.Error())
|
||||
}
|
||||
@@ -77,9 +83,7 @@ func newDependencyBuildCmd(cfg *action.Configuration, out io.Writer) *cobra.Comm
|
||||
}
|
||||
|
||||
f := cmd.Flags()
|
||||
f.BoolVar(&client.Verify, "verify", false, "verify the packages against signatures")
|
||||
f.StringVar(&client.Keyring, "keyring", defaultKeyring(), "keyring containing public keys")
|
||||
f.BoolVar(&client.SkipRefresh, "skip-refresh", false, "do not refresh the local repository cache")
|
||||
addDependencySubcommandFlags(f, client)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ limitations under the License.
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"path/filepath"
|
||||
|
||||
@@ -43,7 +44,7 @@ in the Chart.yaml file, but (b) at the wrong version.
|
||||
`
|
||||
|
||||
// newDependencyUpdateCmd creates a new dependency update command.
|
||||
func newDependencyUpdateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
||||
func newDependencyUpdateCmd(_ *action.Configuration, out io.Writer) *cobra.Command {
|
||||
client := action.NewDependency()
|
||||
|
||||
cmd := &cobra.Command{
|
||||
@@ -57,13 +58,19 @@ func newDependencyUpdateCmd(cfg *action.Configuration, out io.Writer) *cobra.Com
|
||||
if len(args) > 0 {
|
||||
chartpath = filepath.Clean(args[0])
|
||||
}
|
||||
registryClient, err := newRegistryClient(client.CertFile, client.KeyFile, client.CAFile,
|
||||
client.InsecureSkipTLSverify, client.PlainHTTP, client.Username, client.Password)
|
||||
if err != nil {
|
||||
return fmt.Errorf("missing registry client: %w", err)
|
||||
}
|
||||
|
||||
man := &downloader.Manager{
|
||||
Out: out,
|
||||
ChartPath: chartpath,
|
||||
Keyring: client.Keyring,
|
||||
SkipUpdate: client.SkipRefresh,
|
||||
Getters: getter.All(settings),
|
||||
RegistryClient: cfg.RegistryClient,
|
||||
RegistryClient: registryClient,
|
||||
RepositoryConfig: settings.RepositoryConfig,
|
||||
RepositoryCache: settings.RepositoryCache,
|
||||
Debug: settings.Debug,
|
||||
@@ -76,9 +83,7 @@ func newDependencyUpdateCmd(cfg *action.Configuration, out io.Writer) *cobra.Com
|
||||
}
|
||||
|
||||
f := cmd.Flags()
|
||||
f.BoolVar(&client.Verify, "verify", false, "verify the packages against signatures")
|
||||
f.StringVar(&client.Keyring, "keyring", defaultKeyring(), "keyring containing public keys")
|
||||
f.BoolVar(&client.SkipRefresh, "skip-refresh", false, "do not refresh the local repository cache")
|
||||
addDependencySubcommandFlags(f, client)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ func addChartPathOptionsFlags(f *pflag.FlagSet, c *action.ChartPathOptions) {
|
||||
f.StringVar(&c.KeyFile, "key-file", "", "identify HTTPS client using this SSL key file")
|
||||
f.BoolVar(&c.InsecureSkipTLSverify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the chart download")
|
||||
f.BoolVar(&c.PlainHTTP, "plain-http", false, "use insecure HTTP connections for the chart download")
|
||||
f.StringVar(&c.CaFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle")
|
||||
f.StringVar(&c.CAFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle")
|
||||
f.BoolVar(&c.PassCredentialsAll, "pass-credentials", false, "pass credentials to all domains")
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
||||
return compInstall(args, toComplete, client)
|
||||
},
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
registryClient, err := newRegistryClient(client.CertFile, client.KeyFile, client.CaFile,
|
||||
registryClient, err := newRegistryClient(client.CertFile, client.KeyFile, client.CAFile,
|
||||
client.InsecureSkipTLSverify, client.PlainHTTP, client.Username, client.Password)
|
||||
if err != nil {
|
||||
return fmt.Errorf("missing registry client: %w", err)
|
||||
|
||||
@@ -64,7 +64,7 @@ func newPullCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
||||
client.Version = ">0.0.0-0"
|
||||
}
|
||||
|
||||
registryClient, err := newRegistryClient(client.CertFile, client.KeyFile, client.CaFile,
|
||||
registryClient, err := newRegistryClient(client.CertFile, client.KeyFile, client.CAFile,
|
||||
client.InsecureSkipTLSverify, client.PlainHTTP, client.Username, client.Password)
|
||||
if err != nil {
|
||||
return fmt.Errorf("missing registry client: %w", err)
|
||||
|
||||
@@ -226,7 +226,7 @@ func runShow(args []string, client *action.Show) (string, error) {
|
||||
}
|
||||
|
||||
func addRegistryClient(client *action.Show) error {
|
||||
registryClient, err := newRegistryClient(client.CertFile, client.KeyFile, client.CaFile,
|
||||
registryClient, err := newRegistryClient(client.CertFile, client.KeyFile, client.CAFile,
|
||||
client.InsecureSkipTLSverify, client.PlainHTTP, client.Username, client.Password)
|
||||
if err != nil {
|
||||
return fmt.Errorf("missing registry client: %w", err)
|
||||
|
||||
@@ -73,7 +73,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
||||
client.KubeVersion = parsedKubeVersion
|
||||
}
|
||||
|
||||
registryClient, err := newRegistryClient(client.CertFile, client.KeyFile, client.CaFile,
|
||||
registryClient, err := newRegistryClient(client.CertFile, client.KeyFile, client.CAFile,
|
||||
client.InsecureSkipTLSverify, client.PlainHTTP, client.Username, client.Password)
|
||||
if err != nil {
|
||||
return fmt.Errorf("missing registry client: %w", err)
|
||||
|
||||
@@ -102,7 +102,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
client.Namespace = settings.Namespace()
|
||||
|
||||
registryClient, err := newRegistryClient(client.CertFile, client.KeyFile, client.CaFile,
|
||||
registryClient, err := newRegistryClient(client.CertFile, client.KeyFile, client.CAFile,
|
||||
client.InsecureSkipTLSverify, client.PlainHTTP, client.Username, client.Password)
|
||||
if err != nil {
|
||||
return fmt.Errorf("missing registry client: %w", err)
|
||||
|
||||
@@ -34,10 +34,17 @@ import (
|
||||
//
|
||||
// It provides the implementation of 'helm dependency' and its respective subcommands.
|
||||
type Dependency struct {
|
||||
Verify bool
|
||||
Keyring string
|
||||
SkipRefresh bool
|
||||
ColumnWidth uint
|
||||
Verify bool
|
||||
Keyring string
|
||||
SkipRefresh bool
|
||||
ColumnWidth uint
|
||||
Username string
|
||||
Password string
|
||||
CertFile string
|
||||
KeyFile string
|
||||
CAFile string
|
||||
InsecureSkipTLSverify bool
|
||||
PlainHTTP bool
|
||||
}
|
||||
|
||||
// NewDependency creates a new Dependency object with the given configuration.
|
||||
|
||||
@@ -115,7 +115,7 @@ type Install struct {
|
||||
|
||||
// ChartPathOptions captures common options used for controlling chart paths
|
||||
type ChartPathOptions struct {
|
||||
CaFile string // --ca-file
|
||||
CAFile string // --ca-file
|
||||
CertFile string // --cert-file
|
||||
KeyFile string // --key-file
|
||||
InsecureSkipTLSverify bool // --insecure-skip-verify
|
||||
@@ -759,7 +759,7 @@ func (c *ChartPathOptions) LocateChart(name string, settings *cli.EnvSettings) (
|
||||
Getters: getter.All(settings),
|
||||
Options: []getter.Option{
|
||||
getter.WithPassCredentialsAll(c.PassCredentialsAll),
|
||||
getter.WithTLSClientConfig(c.CertFile, c.KeyFile, c.CaFile),
|
||||
getter.WithTLSClientConfig(c.CertFile, c.KeyFile, c.CAFile),
|
||||
getter.WithInsecureSkipVerifyTLS(c.InsecureSkipTLSverify),
|
||||
getter.WithPlainHTTP(c.PlainHTTP),
|
||||
getter.WithBasicAuth(c.Username, c.Password),
|
||||
@@ -778,7 +778,7 @@ func (c *ChartPathOptions) LocateChart(name string, settings *cli.EnvSettings) (
|
||||
}
|
||||
if c.RepoURL != "" {
|
||||
chartURL, err := repo.FindChartInAuthAndTLSAndPassRepoURL(c.RepoURL, c.Username, c.Password, name, version,
|
||||
c.CertFile, c.KeyFile, c.CaFile, c.InsecureSkipTLSverify, c.PassCredentialsAll, getter.All(settings))
|
||||
c.CertFile, c.KeyFile, c.CAFile, c.InsecureSkipTLSverify, c.PassCredentialsAll, getter.All(settings))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ func (p *Pull) Run(chartRef string) (string, error) {
|
||||
Options: []getter.Option{
|
||||
getter.WithBasicAuth(p.Username, p.Password),
|
||||
getter.WithPassCredentialsAll(p.PassCredentialsAll),
|
||||
getter.WithTLSClientConfig(p.CertFile, p.KeyFile, p.CaFile),
|
||||
getter.WithTLSClientConfig(p.CertFile, p.KeyFile, p.CAFile),
|
||||
getter.WithInsecureSkipVerifyTLS(p.InsecureSkipTLSverify),
|
||||
getter.WithPlainHTTP(p.PlainHTTP),
|
||||
},
|
||||
@@ -122,7 +122,7 @@ func (p *Pull) Run(chartRef string) (string, error) {
|
||||
}
|
||||
|
||||
if p.RepoURL != "" {
|
||||
chartURL, err := repo.FindChartInAuthAndTLSAndPassRepoURL(p.RepoURL, p.Username, p.Password, chartRef, p.Version, p.CertFile, p.KeyFile, p.CaFile, p.InsecureSkipTLSverify, p.PassCredentialsAll, getter.All(p.Settings))
|
||||
chartURL, err := repo.FindChartInAuthAndTLSAndPassRepoURL(p.RepoURL, p.Username, p.Password, chartRef, p.Version, p.CertFile, p.KeyFile, p.CAFile, p.InsecureSkipTLSverify, p.PassCredentialsAll, getter.All(p.Settings))
|
||||
if err != nil {
|
||||
return out.String(), err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user