Repository: helm/helm
Pull request #8368 (2020-06-29 08:39:18)

Fix some go-lint warnings
Signed-off-by: zouyu <zouy.fnst@cn.fujitsu.com>

<!--  Thanks for sending a pull request!  Here are some tips for you:
1. Make sure to read the Contributing Guide before submitting your PR: https://github.com/helm/helm/blob/master/CONTRIBUTING.md
2. If this PR closes another issue, add 'closes #<issue number>' somewhere in the PR summary. GitHub will automatically close that issue when this PR gets merged. Alternatively, adding 'refs #<issue number>' will not close the issue, but help provide the reviewer more context.-->

**What this PR does / why we need it**:
fix some go-lint warnings:
- package comment should be of the form "Package postrender ..."
- comment on exported const HelmStorageType should be of the form "HelmStorageType ..."

**Special notes for your reviewer**:

**If applicable**:
- [ ] this PR contains documentation
- [ ] this PR contains unit tests
- [ ] this PR has been tested for backwards compatibility



Patch:
diff --git a/cmd/helm/flags.go b/cmd/helm/flags.go
index 544fb7608..040773d7b 100644
--- a/cmd/helm/flags.go
+++ b/cmd/helm/flags.go
@@ -52,7 +52,6 @@ func addChartPathOptionsFlags(f *pflag.FlagSet, c *action.ChartPathOptions) {
 	f.StringVar(&c.Password, "password", "", "chart repository password where to locate the requested chart")
 	f.StringVar(&c.CertFile, "cert-file", "", "identify HTTPS client using this SSL certificate file")
 	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.StringVar(&c.CaFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle")
 }
 
diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go
index 474a3d2d4..fcc7315f5 100644
--- a/cmd/helm/helm.go
+++ b/cmd/helm/helm.go
@@ -68,11 +68,7 @@ func main() {
 	initKubeLogs()
 
 	actionConfig := new(action.Configuration)
-	cmd, err := newRootCmd(actionConfig, os.Stdout, os.Args[1:])
-	if err != nil {
-		debug("%+v", err)
-		os.Exit(1)
-	}
+	cmd := newRootCmd(actionConfig, os.Stdout, os.Args[1:])
 
 	// run when each command's execute method is called
 	cobra.OnInitialize(func() {
diff --git a/cmd/helm/root.go b/cmd/helm/root.go
index 20dd1d93b..69f5855d9 100644
--- a/cmd/helm/root.go
+++ b/cmd/helm/root.go
@@ -68,7 +68,7 @@ By default, the default directories depend on the Operating System. The defaults
 | Windows          | %TEMP%\helm               | %APPDATA%\helm                 | %APPDATA%\helm          |
 `
 
-func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string) (*cobra.Command, error) {
+func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string) *cobra.Command {
 	cmd := &cobra.Command{
 		Use:          "helm",
 		Short:        "The Helm package manager for Kubernetes.",
@@ -175,10 +175,10 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string
 	registryClient, err := registry.NewClient(
 		registry.ClientOptDebug(settings.Debug),
 		registry.ClientOptWriter(out),
-		registry.ClientOptCredentialsFile(settings.RegistryConfig),
 	)
 	if err != nil {
-		return nil, err
+		// TODO: don't panic here, refactor newRootCmd to return error
+		panic(err)
 	}
 	actionConfig.RegistryClient = registryClient
 	cmd.AddCommand(
@@ -189,5 +189,5 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string
 	// Find and add plugins
 	loadPlugins(cmd, out)
 
-	return cmd, nil
+	return cmd
 }
diff --git a/internal/experimental/registry/client.go b/internal/experimental/registry/client.go
index 540eddfa3..f664c9f38 100644
--- a/internal/experimental/registry/client.go
+++ b/internal/experimental/registry/client.go
@@ -42,13 +42,11 @@ const (
 type (
 	// Client works with OCI-compliant registries and local Helm chart cache
 	Client struct {
-		debug bool
-		// path to repository config file e.g. ~/.docker/config.json
-		credentialsFile string
-		out             io.Writer
-		authorizer      *Authorizer
-		resolver        *Resolver
-		cache           *Cache
+		debug      bool
+		out        io.Writer
+		authorizer *Authorizer
+		resolver   *Resolver
+		cache      *Cache
 	}
 )
 
@@ -61,11 +59,9 @@ func NewClient(opts ...ClientOption) (*Client, error) {
 		opt(client)
 	}
 	// set defaults if fields are missing
-	if client.credentialsFile == "" {
-		client.credentialsFile = helmpath.CachePath("registry", CredentialsFileBasename)
-	}
 	if client.authorizer == nil {
-		authClient, err := auth.NewClient(client.credentialsFile)
+		credentialsFile := helmpath.CachePath("registry", CredentialsFileBasename)
+		authClient, err := auth.NewClient(credentialsFile)
 		if err != nil {
 			return nil, err
 		}
diff --git a/internal/experimental/registry/client_opts.go b/internal/experimental/registry/client_opts.go
index 76b527492..cd295813a 100644
--- a/internal/experimental/registry/client_opts.go
+++ b/internal/experimental/registry/client_opts.go
@@ -60,10 +60,3 @@ func ClientOptCache(cache *Cache) ClientOption {
 		client.cache = cache
 	}
 }
-
-// ClientOptCache returns a function that sets the cache setting on a client options set
-func ClientOptCredentialsFile(credentialsFile string) ClientOption {
-	return func(client *Client) {
-		client.credentialsFile = credentialsFile
-	}
-}
diff --git a/pkg/action/install.go b/pkg/action/install.go
index 00fb208b0..351e0928c 100644
--- a/pkg/action/install.go
+++ b/pkg/action/install.go
@@ -104,16 +104,15 @@ type Install struct {
 
 // ChartPathOptions captures common options used for controlling chart paths
 type ChartPathOptions struct {
-	CaFile                string // --ca-file
-	CertFile              string // --cert-file
-	KeyFile               string // --key-file
-	InsecureSkipTLSverify bool   // --insecure-skip-verify
-	Keyring               string // --keyring
-	Password              string // --password
-	RepoURL               string // --repo
-	Username              string // --username
-	Verify                bool   // --verify
-	Version               string // --version
+	CaFile   string // --ca-file
+	CertFile string // --cert-file
+	KeyFile  string // --key-file
+	Keyring  string // --keyring
+	Password string // --password
+	RepoURL  string // --repo
+	Username string // --username
+	Verify   bool   // --verify
+	Version  string // --version
 }
 
 // NewInstall creates a new Install object with the given configuration.
@@ -645,7 +644,6 @@ func (c *ChartPathOptions) LocateChart(name string, settings *cli.EnvSettings) (
 		Options: []getter.Option{
 			getter.WithBasicAuth(c.Username, c.Password),
 			getter.WithTLSClientConfig(c.CertFile, c.KeyFile, c.CaFile),
-			getter.WithInsecureSkipVerifyTLS(c.InsecureSkipTLSverify),
 		},
 		RepositoryConfig: settings.RepositoryConfig,
 		RepositoryCache:  settings.RepositoryCache,
diff --git a/pkg/action/pull.go b/pkg/action/pull.go
index a46e98bae..ee20bbe83 100644
--- a/pkg/action/pull.go
+++ b/pkg/action/pull.go
@@ -64,7 +64,6 @@ func (p *Pull) Run(chartRef string) (string, error) {
 		Options: []getter.Option{
 			getter.WithBasicAuth(p.Username, p.Password),
 			getter.WithTLSClientConfig(p.CertFile, p.KeyFile, p.CaFile),
-			getter.WithInsecureSkipVerifyTLS(p.InsecureSkipTLSverify),
 		},
 		RepositoryConfig: p.Settings.RepositoryConfig,
 		RepositoryCache:  p.Settings.RepositoryCache,
diff --git a/pkg/postrender/postrender.go b/pkg/postrender/postrender.go
index 76f0f5a74..3af384290 100644
--- a/pkg/postrender/postrender.go
+++ b/pkg/postrender/postrender.go
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-// package postrender contains an interface that can be implemented for custom
+// Package postrender contains an interface that can be implemented for custom
 // post-renderers and an exec implementation that can be used for arbitrary
 // binaries and scripts
 package postrender
diff --git a/pkg/storage/storage.go b/pkg/storage/storage.go
index c195120cd..2dfa3f615 100644
--- a/pkg/storage/storage.go
+++ b/pkg/storage/storage.go
@@ -27,7 +27,7 @@ import (
 	"helm.sh/helm/v3/pkg/storage/driver"
 )
 
-// The type field of the Kubernetes storage object which stores the Helm release
+// HelmStorageType is the type field of the Kubernetes storage object which stores the Helm release
 // version. It is modified slightly replacing the '/': sh.helm/release.v1
 // Note: The version 'v1' is incremented if the release object metadata is
 // modified between major releases.


Test patch:
diff --git a/cmd/helm/helm_test.go b/cmd/helm/helm_test.go
index 5e59c41ed..9ba9d78fb 100644
--- a/cmd/helm/helm_test.go
+++ b/cmd/helm/helm_test.go
@@ -115,11 +115,7 @@ func executeActionCommandStdinC(store *storage.Storage, in *os.File, cmd string)
 		Log:          func(format string, v ...interface{}) {},
 	}
 
-	root, err := newRootCmd(actionConfig, buf, args)
-	if err != nil {
-		return nil, "", err
-	}
-
+	root := newRootCmd(actionConfig, buf, args)
 	root.SetOut(buf)
 	root.SetErr(buf)
 	root.SetArgs(args)