From 2f861d4c1736526ab0400c0e7e5f3704347292dd Mon Sep 17 00:00:00 2001 From: pytimer Date: Fri, 25 Feb 2022 17:34:53 +0800 Subject: [PATCH] Install or upgrade supports OCI insecure registry Signed-off-by: pytimer --- cmd/helm/flags.go | 1 + cmd/helm/pull.go | 1 - pkg/action/install.go | 7 +++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/helm/flags.go b/cmd/helm/flags.go index 6a59101b7..31dd27d2f 100644 --- a/cmd/helm/flags.go +++ b/cmd/helm/flags.go @@ -58,6 +58,7 @@ func addChartPathOptionsFlags(f *pflag.FlagSet, c *action.ChartPathOptions) { f.BoolVar(&c.InsecureSkipTLSverify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the chart download") 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") + f.BoolVar(&c.PlainHTTP, "plain-http", false, "use plain http to connect oci registry") } // bindOutputFlag will add the output flag to the given command and bind the diff --git a/cmd/helm/pull.go b/cmd/helm/pull.go index 51d679ae6..b1c04fe0a 100644 --- a/cmd/helm/pull.go +++ b/cmd/helm/pull.go @@ -81,7 +81,6 @@ func newPullCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.BoolVar(&client.VerifyLater, "prov", false, "fetch the provenance file, but don't perform verification") f.StringVar(&client.UntarDir, "untardir", ".", "if untar is specified, this flag specifies the name of the directory into which the chart is expanded") f.StringVarP(&client.DestDir, "destination", "d", ".", "location to write the chart. If this and tardir are specified, tardir is appended to this") - f.BoolVar(&client.PlainHTTP, "plain-http", false, "use plain http and not https to connect oci registry") addChartPathOptionsFlags(f, &client.ChartPathOptions) err := cmd.RegisterFlagCompletionFunc("version", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { diff --git a/pkg/action/install.go b/pkg/action/install.go index 32be904b4..adf237db6 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -117,6 +117,7 @@ type ChartPathOptions struct { Username string // --username Verify bool // --verify Version string // --version + PlainHTTP bool // --plain-http // registryClient provides a registry client but is not added with // options from a flag @@ -694,6 +695,12 @@ func (c *ChartPathOptions) LocateChart(name string, settings *cli.EnvSettings) ( return name, errors.Errorf("path %q not found", name) } + if c.InsecureSkipTLSverify { + if err := c.registryClient.WithResolver(c.InsecureSkipTLSverify, c.PlainHTTP); err != nil { + return "", err + } + } + dl := downloader.ChartDownloader{ Out: os.Stdout, Keyring: c.Keyring,