From 4344999f9d1fa3f313fb00a433f33675f1bbe9e7 Mon Sep 17 00:00:00 2001 From: ifuryst Date: Mon, 1 Jul 2024 20:55:17 +0800 Subject: [PATCH] refactor: resolve name collision, improve naming conventions, and correct spelling errors. * Resolve name collision with imported package name. * Explicitly indicate unhandled responses. * Rename variables to follow camelCase naming convention. * Correct spelling errors. Signed-off-by: ifuryst --- CONTRIBUTING.md | 10 ++-- cmd/helm/completion.go | 6 +- cmd/helm/create.go | 16 +++--- cmd/helm/create_test.go | 46 +++++++++------ cmd/helm/dependency.go | 6 +- cmd/helm/dependency_build.go | 10 ++-- cmd/helm/dependency_update_test.go | 2 +- cmd/helm/env.go | 4 +- cmd/helm/flags.go | 12 ++-- cmd/helm/get_hooks.go | 2 +- cmd/helm/get_manifest.go | 2 +- cmd/helm/get_metadata.go | 6 +- cmd/helm/get_notes.go | 2 +- cmd/helm/get_values.go | 10 ++-- cmd/helm/helm.go | 12 ++-- cmd/helm/history.go | 25 +++----- cmd/helm/install.go | 18 +++--- cmd/helm/lint.go | 14 ++--- cmd/helm/list.go | 16 +++--- cmd/helm/load_plugins.go | 2 +- cmd/helm/package.go | 2 +- cmd/helm/plugin_install.go | 2 +- cmd/helm/plugin_list.go | 8 +-- cmd/helm/plugin_uninstall.go | 2 +- cmd/helm/plugin_update.go | 2 +- cmd/helm/pull.go | 4 +- cmd/helm/push.go | 10 ++-- cmd/helm/release_testing.go | 8 +-- cmd/helm/repo_add.go | 14 ++--- cmd/helm/repo_list.go | 26 ++++----- cmd/helm/repo_remove.go | 4 +- cmd/helm/repo_update.go | 14 ++--- cmd/helm/repo_update_test.go | 13 +++-- cmd/helm/rollback.go | 2 +- cmd/helm/root.go | 22 +++---- cmd/helm/search_hub_test.go | 12 ++-- cmd/helm/show.go | 12 ++-- cmd/helm/status.go | 10 ++-- cmd/helm/template.go | 10 ++-- cmd/helm/uninstall.go | 4 +- cmd/helm/upgrade.go | 26 ++++----- cmd/helm/verify.go | 2 +- cmd/helm/version.go | 4 +- internal/monocular/search_test.go | 2 +- pkg/action/action.go | 16 +++--- pkg/action/dependency.go | 14 ++--- pkg/action/install.go | 24 ++++---- pkg/action/pull.go | 10 ++-- pkg/action/release_testing.go | 4 +- pkg/action/show.go | 16 +++--- pkg/action/upgrade.go | 2 +- pkg/action/verify.go | 6 +- pkg/chart/chart.go | 10 ++-- pkg/chartutil/capabilities.go | 8 +-- pkg/chartutil/chartfile.go | 18 +++--- pkg/chartutil/chartfile_test.go | 10 ++-- pkg/chartutil/coalesce.go | 38 ++++++------ pkg/chartutil/create.go | 30 +++++----- pkg/chartutil/create_test.go | 10 ++-- pkg/chartutil/dependencies.go | 2 +- pkg/chartutil/jsonschema.go | 6 +- pkg/chartutil/save.go | 18 +++--- pkg/chartutil/values.go | 10 ++-- pkg/cli/environment.go | 8 +-- pkg/downloader/chart_downloader.go | 24 ++++---- pkg/downloader/manager.go | 38 ++++++------ pkg/getter/getter.go | 2 +- pkg/getter/httpgetter_test.go | 8 +-- pkg/getter/plugingetter.go | 8 +-- pkg/helmpath/lazypath.go | 4 +- pkg/kube/client.go | 2 +- pkg/kube/factory.go | 2 +- pkg/lint/lint.go | 2 +- pkg/lint/rules/chartfile.go | 6 +- pkg/lint/rules/chartfile_test.go | 10 ++-- pkg/plugin/installer/http_installer_test.go | 4 +- pkg/provenance/sign_test.go | 64 +++++++++++---------- pkg/registry/client.go | 22 +++---- pkg/registry/util.go | 2 +- pkg/repo/chartrepo.go | 2 +- 80 files changed, 455 insertions(+), 441 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 20015e60a..1526d45fb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -104,7 +104,7 @@ specific upcoming bugfix or feature release could fall into one of two different Issues and PRs which are deemed backwards-incompatible may be added to the discussion items for Helm 4 with [label:v4.x](https://github.com/helm/helm/labels/v4.x). An issue or PR that we are not -sure we will be addressing will not be added to any milestone. +sure if we will be addressing will not be added to any milestone. A milestone (and hence release) can be closed when all outstanding issues/PRs have been closed or moved to another milestone and the associated release has been published. @@ -115,7 +115,7 @@ Helm maintains a strong commitment to backward compatibility. All of our changes formats are backward compatible from one major release to the next. No features, flags, or commands are removed or substantially modified (unless we need to fix a security issue). -We also remain committed to not changing publicly accessible Go library definitions inside of the `pkg/` directory of our source code in a non-backwards-compatible way. +We also remain committed to not changing publicly accessible Go library definitions inside the `pkg/` directory of our source code in a non-backwards-compatible way. For more details on Helm’s minor and patch release backwards-compatibility rules, please read [HIP-0004](https://github.com/helm/community/blob/main/hips/hip-0004.md) @@ -144,8 +144,8 @@ There are 5 types of issues (each with their own corresponding [label](#labels)) discussion, these can turn into `feature` or `bug` issues. - `proposal`: Used for items (like this one) that propose a new ideas or functionality that require a larger community discussion. This allows for feedback from others in the community before a - feature is actually developed. This is not needed for small additions. Final word on whether or - not a feature needs a proposal is up to the core maintainers. All issues that are proposals should + feature is actually developed. This is not needed for small additions. Final word on whether + a feature needs a proposal is up to the core maintainers. All issues that are proposals should both have a label and an issue title of "Proposal: [the rest of the title]." A proposal can become a `feature` and does not require a milestone. - `feature`: These track specific feature requests and ideas until they are complete. They can @@ -163,7 +163,7 @@ below. 2. Triage - The maintainer in charge of triaging will apply the proper labels for the issue. This includes labels for priority, type, and metadata (such as `good first issue`). The only issue priority - we will be tracking is whether or not the issue is "critical." If additional levels are needed + we will be tracking is whether the issue is "critical." If additional levels are needed in the future, we will add them. - (If needed) Clean up the title to succinctly and clearly state the issue. Also ensure that proposals are prefaced with "Proposal: [the rest of the title]". diff --git a/cmd/helm/completion.go b/cmd/helm/completion.go index 9f31ea741..2a4f6f734 100644 --- a/cmd/helm/completion.go +++ b/cmd/helm/completion.go @@ -166,7 +166,7 @@ else complete -o default -o nospace -F __start_helm %[1]s fi ` - fmt.Fprintf(out, renamedBinaryHook, binary) + _, _ = fmt.Fprintf(out, renamedBinaryHook, binary) } return err @@ -189,11 +189,11 @@ func runCompletionZsh(out io.Writer, cmd *cobra.Command) error { # the user renamed the helm binary compdef _helm %[1]s ` - fmt.Fprintf(out, renamedBinaryHook, binary) + _, _ = fmt.Fprintf(out, renamedBinaryHook, binary) } // Cobra doesn't source zsh completion file, explicitly doing it here - fmt.Fprintf(out, "compdef _helm helm") + _, _ = fmt.Fprintf(out, "compdef _helm helm") return err } diff --git a/cmd/helm/create.go b/cmd/helm/create.go index b79752efb..6be4927c6 100644 --- a/cmd/helm/create.go +++ b/cmd/helm/create.go @@ -85,11 +85,11 @@ func newCreateCmd(out io.Writer) *cobra.Command { } func (o *createOptions) run(out io.Writer) error { - fmt.Fprintf(out, "Creating %s\n", o.name) + _, _ = fmt.Fprintf(out, "Creating %s\n", o.name) - chartname := filepath.Base(o.name) - cfile := &chart.Metadata{ - Name: chartname, + chartName := filepath.Base(o.name) + chartFile := &chart.Metadata{ + Name: chartName, Description: "A Helm chart for Kubernetes", Type: "application", Version: "0.1.0", @@ -99,15 +99,15 @@ func (o *createOptions) run(out io.Writer) error { if o.starter != "" { // Create from the starter - lstarter := filepath.Join(o.starterDir, o.starter) + starterPath := filepath.Join(o.starterDir, o.starter) // If path is absolute, we don't want to prefix it with helm starters folder if filepath.IsAbs(o.starter) { - lstarter = o.starter + starterPath = o.starter } - return chartutil.CreateFrom(cfile, filepath.Dir(o.name), lstarter) + return chartutil.CreateFrom(chartFile, filepath.Dir(o.name), starterPath) } chartutil.Stderr = out - _, err := chartutil.Create(chartname, filepath.Dir(o.name)) + _, err := chartutil.Create(chartName, filepath.Dir(o.name)) return err } diff --git a/cmd/helm/create_test.go b/cmd/helm/create_test.go index 1a22d058f..f7a38697b 100644 --- a/cmd/helm/create_test.go +++ b/cmd/helm/create_test.go @@ -35,7 +35,7 @@ func TestCreateCmd(t *testing.T) { dir := t.TempDir() defer testChdir(t, dir)() - // Run a create + // Run a create command if _, _, err := executeActionCommand("create " + cname); err != nil { t.Fatalf("Failed to run create: %s", err) } @@ -64,24 +64,30 @@ func TestCreateStarterCmd(t *testing.T) { ensure.HelmHome(t) cname := "testchart" defer resetEnv()() - os.MkdirAll(helmpath.CachePath(), 0755) + err := os.MkdirAll(helmpath.CachePath(), 0755) + if err != nil { + t.Fatalf("Could not create cache directory: %s", err) + } defer testChdir(t, helmpath.CachePath())() // Create a starter. - starterchart := helmpath.DataPath("starters") - os.MkdirAll(starterchart, 0755) - if dest, err := chartutil.Create("starterchart", starterchart); err != nil { + starterChart := helmpath.DataPath("starters") + err = os.MkdirAll(starterChart, 0755) + if err != nil { + t.Fatalf("Could not create starter chart: %s", err) + } + if dest, err := chartutil.Create("starterChart", starterChart); err != nil { t.Fatalf("Could not create chart: %s", err) } else { t.Logf("Created %s", dest) } - tplpath := filepath.Join(starterchart, "starterchart", "templates", "foo.tpl") - if err := os.WriteFile(tplpath, []byte("test"), 0644); err != nil { + tplPath := filepath.Join(starterChart, "starterChart", "templates", "foo.tpl") + if err := os.WriteFile(tplPath, []byte("test"), 0644); err != nil { t.Fatalf("Could not write template: %s", err) } - // Run a create - if _, _, err := executeActionCommand(fmt.Sprintf("create --starter=starterchart %s", cname)); err != nil { + // Run a create command + if _, _, err := executeActionCommand(fmt.Sprintf("create --starter=starterChart %s", cname)); err != nil { t.Errorf("Failed to run create: %s", err) return } @@ -131,24 +137,30 @@ func TestCreateStarterAbsoluteCmd(t *testing.T) { cname := "testchart" // Create a starter. - starterchart := helmpath.DataPath("starters") - os.MkdirAll(starterchart, 0755) - if dest, err := chartutil.Create("starterchart", starterchart); err != nil { + starterChart := helmpath.DataPath("starters") + err := os.MkdirAll(starterChart, 0755) + if err != nil { + t.Fatalf("Could not create starter chart: %s", err) + } + if dest, err := chartutil.Create("starterChart", starterChart); err != nil { t.Fatalf("Could not create chart: %s", err) } else { t.Logf("Created %s", dest) } - tplpath := filepath.Join(starterchart, "starterchart", "templates", "foo.tpl") - if err := os.WriteFile(tplpath, []byte("test"), 0644); err != nil { + tplPath := filepath.Join(starterChart, "starterChart", "templates", "foo.tpl") + if err := os.WriteFile(tplPath, []byte("test"), 0644); err != nil { t.Fatalf("Could not write template: %s", err) } - os.MkdirAll(helmpath.CachePath(), 0755) + err = os.MkdirAll(helmpath.CachePath(), 0755) + if err != nil { + t.Fatalf("Could not create cache directory: %s", err) + } defer testChdir(t, helmpath.CachePath())() - starterChartPath := filepath.Join(starterchart, "starterchart") + starterChartPath := filepath.Join(starterChart, "starterChart") - // Run a create + // Run a create command if _, _, err := executeActionCommand(fmt.Sprintf("create --starter=%s %s", starterChartPath, cname)); err != nil { t.Errorf("Failed to run create: %s", err) return diff --git a/cmd/helm/dependency.go b/cmd/helm/dependency.go index 228c73c80..13154de24 100644 --- a/cmd/helm/dependency.go +++ b/cmd/helm/dependency.go @@ -107,11 +107,11 @@ func newDependencyListCmd(out io.Writer) *cobra.Command { Long: dependencyListDesc, Args: require.MaximumNArgs(1), RunE: func(_ *cobra.Command, args []string) error { - chartpath := "." + chartPath := "." if len(args) > 0 { - chartpath = filepath.Clean(args[0]) + chartPath = filepath.Clean(args[0]) } - return client.List(chartpath, out) + return client.List(chartPath, out) }, } diff --git a/cmd/helm/dependency_build.go b/cmd/helm/dependency_build.go index 2cf0c6c81..a4457c092 100644 --- a/cmd/helm/dependency_build.go +++ b/cmd/helm/dependency_build.go @@ -16,6 +16,7 @@ limitations under the License. package main import ( + "errors" "fmt" "io" "os" @@ -50,13 +51,13 @@ func newDependencyBuildCmd(cfg *action.Configuration, out io.Writer) *cobra.Comm Long: dependencyBuildDesc, Args: require.MaximumNArgs(1), RunE: func(_ *cobra.Command, args []string) error { - chartpath := "." + chartPath := "." if len(args) > 0 { - chartpath = filepath.Clean(args[0]) + chartPath = filepath.Clean(args[0]) } man := &downloader.Manager{ Out: out, - ChartPath: chartpath, + ChartPath: chartPath, Keyring: client.Keyring, SkipUpdate: client.SkipRefresh, Getters: getter.All(settings), @@ -69,7 +70,8 @@ func newDependencyBuildCmd(cfg *action.Configuration, out io.Writer) *cobra.Comm man.Verify = downloader.VerifyIfPossible } err := man.Build() - if e, ok := err.(downloader.ErrRepoNotFound); ok { + var e downloader.ErrRepoNotFound + if errors.As(err, &e) { return fmt.Errorf("%s. Please add the missing repos via 'helm repo add'", e.Error()) } return err diff --git a/cmd/helm/dependency_update_test.go b/cmd/helm/dependency_update_test.go index 1a1e0468f..251a4b599 100644 --- a/cmd/helm/dependency_update_test.go +++ b/cmd/helm/dependency_update_test.go @@ -106,7 +106,7 @@ func TestDependencyUpdateCmd(t *testing.T) { {Name: "reqtest", Version: "0.1.0", Repository: srv.URL()}, {Name: "compressedchart", Version: "0.3.0", Repository: srv.URL()}, } - if err := chartutil.SaveChartfile(dir(chartname, "Chart.yaml"), md); err != nil { + if err := chartutil.SaveChartFile(dir(chartname, "Chart.yaml"), md); err != nil { t.Fatal(err) } diff --git a/cmd/helm/env.go b/cmd/helm/env.go index 83ee32895..0a5dcc6b1 100644 --- a/cmd/helm/env.go +++ b/cmd/helm/env.go @@ -53,10 +53,10 @@ func newEnvCmd(out io.Writer) *cobra.Command { keys := getSortedEnvVarKeys() for _, k := range keys { - fmt.Fprintf(out, "%s=\"%s\"\n", k, envVars[k]) + _, _ = fmt.Fprintf(out, "%s=\"%s\"\n", k, envVars[k]) } } else { - fmt.Fprintf(out, "%s\n", envVars[args[0]]) + _, _ = fmt.Fprintf(out, "%s\n", envVars[args[0]]) } }, } diff --git a/cmd/helm/flags.go b/cmd/helm/flags.go index 62e9f90fa..0a2818845 100644 --- a/cmd/helm/flags.go +++ b/cmd/helm/flags.go @@ -60,7 +60,7 @@ 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.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.BoolVar(&c.PassCredentialsAll, "pass-credentials", false, "pass credentials to all domains") @@ -107,11 +107,11 @@ func (o *outputValue) Type() string { } func (o *outputValue) Set(s string) error { - outfmt, err := output.ParseFormat(s) + outFmt, err := output.ParseFormat(s) if err != nil { return err } - *o = outputValue(outfmt) + *o = outputValue(outFmt) return nil } @@ -240,9 +240,9 @@ func addKlogFlags(fs *pflag.FlagSet) { if fs.Lookup(fl.Name) != nil { return } - newflag := pflag.PFlagFromGoFlag(fl) - newflag.Hidden = true - fs.AddFlag(newflag) + newFlag := pflag.PFlagFromGoFlag(fl) + newFlag.Hidden = true + fs.AddFlag(newFlag) }) } diff --git a/cmd/helm/get_hooks.go b/cmd/helm/get_hooks.go index 6ba5094e4..4588111be 100644 --- a/cmd/helm/get_hooks.go +++ b/cmd/helm/get_hooks.go @@ -53,7 +53,7 @@ func newGetHooksCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { return err } for _, hook := range res.Hooks { - fmt.Fprintf(out, "---\n# Source: %s\n%s\n", hook.Path, hook.Manifest) + _, _ = fmt.Fprintf(out, "---\n# Source: %s\n%s\n", hook.Path, hook.Manifest) } return nil }, diff --git a/cmd/helm/get_manifest.go b/cmd/helm/get_manifest.go index 0df100259..d5255edf3 100644 --- a/cmd/helm/get_manifest.go +++ b/cmd/helm/get_manifest.go @@ -54,7 +54,7 @@ func newGetManifestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command if err != nil { return err } - fmt.Fprintln(out, res.Manifest) + _, _ = fmt.Fprintln(out, res.Manifest) return nil }, } diff --git a/cmd/helm/get_metadata.go b/cmd/helm/get_metadata.go index 084323275..a4f5ee6e5 100644 --- a/cmd/helm/get_metadata.go +++ b/cmd/helm/get_metadata.go @@ -33,7 +33,7 @@ type metadataWriter struct { } func newGetMetadataCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - var outfmt output.Format + var outFmt output.Format client := action.NewGetMetadata(cfg) cmd := &cobra.Command{ @@ -51,7 +51,7 @@ func newGetMetadataCmd(cfg *action.Configuration, out io.Writer) *cobra.Command if err != nil { return err } - return outfmt.Write(out, &metadataWriter{releaseMetadata}) + return outFmt.Write(out, &metadataWriter{releaseMetadata}) }, } @@ -68,7 +68,7 @@ func newGetMetadataCmd(cfg *action.Configuration, out io.Writer) *cobra.Command log.Fatal(err) } - bindOutputFlag(cmd, &outfmt) + bindOutputFlag(cmd, &outFmt) return cmd } diff --git a/cmd/helm/get_notes.go b/cmd/helm/get_notes.go index 6ac2a0450..8a1090ada 100644 --- a/cmd/helm/get_notes.go +++ b/cmd/helm/get_notes.go @@ -51,7 +51,7 @@ func newGetNotesCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { return err } if len(res.Info.Notes) > 0 { - fmt.Fprintf(out, "NOTES:\n%s\n", res.Info.Notes) + _, _ = fmt.Fprintf(out, "NOTES:\n%s\n", res.Info.Notes) } return nil }, diff --git a/cmd/helm/get_values.go b/cmd/helm/get_values.go index c3fb8c252..bdb7a6867 100644 --- a/cmd/helm/get_values.go +++ b/cmd/helm/get_values.go @@ -38,7 +38,7 @@ type valuesWriter struct { } func newGetValuesCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { - var outfmt output.Format + var outFmt output.Format client := action.NewGetValues(cfg) cmd := &cobra.Command{ @@ -57,7 +57,7 @@ func newGetValuesCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { if err != nil { return err } - return outfmt.Write(out, &valuesWriter{vals, client.AllValues}) + return outFmt.Write(out, &valuesWriter{vals, client.AllValues}) }, } @@ -75,16 +75,16 @@ func newGetValuesCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } f.BoolVarP(&client.AllValues, "all", "a", false, "dump all (computed) values") - bindOutputFlag(cmd, &outfmt) + bindOutputFlag(cmd, &outFmt) return cmd } func (v valuesWriter) WriteTable(out io.Writer) error { if v.allValues { - fmt.Fprintln(out, "COMPUTED VALUES:") + _, _ = fmt.Fprintln(out, "COMPUTED VALUES:") } else { - fmt.Fprintln(out, "USER-SUPPLIED VALUES:") + _, _ = fmt.Fprintln(out, "USER-SUPPLIED VALUES:") } return output.EncodeYAML(out, v.vals) } diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 553da5098..92c0c943a 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -17,6 +17,7 @@ limitations under the License. package main // import "helm.sh/helm/v3/cmd/helm" import ( + "errors" "fmt" "io" "log" @@ -46,13 +47,13 @@ func init() { func debug(format string, v ...interface{}) { if settings.Debug { format = fmt.Sprintf("[debug] %s\n", format) - log.Output(2, fmt.Sprintf(format, v...)) + _ = log.Output(2, fmt.Sprintf(format, v...)) } } func warning(format string, v ...interface{}) { format = fmt.Sprintf("WARNING: %s\n", format) - fmt.Fprintf(os.Stderr, format, v...) + _, _ = fmt.Fprintf(os.Stderr, format, v...) } func main() { @@ -82,8 +83,9 @@ func main() { if err := cmd.Execute(); err != nil { debug("%+v", err) - switch e := err.(type) { - case pluginError: + var e pluginError + switch { + case errors.As(err, &e): os.Exit(e.code) default: os.Exit(1) @@ -114,7 +116,7 @@ func loadReleasesInMemory(actionConfig *action.Configuration) { log.Fatal("Unable to read memory driver data", err) } - releases := []*release.Release{} + var releases []*release.Release if err := yaml.Unmarshal(b, &releases); err != nil { log.Fatal("Unable to unmarshal memory driver data: ", err) } diff --git a/cmd/helm/history.go b/cmd/helm/history.go index 42796fab8..173539424 100644 --- a/cmd/helm/history.go +++ b/cmd/helm/history.go @@ -52,7 +52,7 @@ The historical release set is printed as a formatted table, e.g: func newHistoryCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { client := action.NewHistory(cfg) - var outfmt output.Format + var outFmt output.Format cmd := &cobra.Command{ Use: "history RELEASE_NAME", @@ -72,13 +72,13 @@ func newHistoryCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { return err } - return outfmt.Write(out, history) + return outFmt.Write(out, history) }, } f := cmd.Flags() f.IntVar(&client.Max, "max", 256, "maximum number of revision to include in history") - bindOutputFlag(cmd, &outfmt) + bindOutputFlag(cmd, &outFmt) return cmd } @@ -136,7 +136,7 @@ func getHistory(client *action.History, name string) (releaseHistory, error) { func getReleaseHistory(rls []*release.Release) (history releaseHistory) { for i := len(rls) - 1; i >= 0; i-- { r := rls[i] - c := formatChartname(r.Chart) + c := formatChartName(r.Chart) s := r.Info.Status.String() v := r.Version d := r.Info.Description @@ -159,7 +159,7 @@ func getReleaseHistory(rls []*release.Release) (history releaseHistory) { return history } -func formatChartname(c *chart.Chart) string { +func formatChartName(c *chart.Chart) string { if c == nil || c.Metadata == nil { // This is an edge case that has happened in prod, though we don't // know how: https://github.com/helm/helm/issues/1347 @@ -177,22 +177,15 @@ func formatAppVersion(c *chart.Chart) string { return c.AppVersion() } -func min(x, y int) int { - if x < y { - return x - } - return y -} - func compListRevisions(_ string, cfg *action.Configuration, releaseName string) ([]string, cobra.ShellCompDirective) { client := action.NewHistory(cfg) var revisions []string if hist, err := client.Run(releaseName); err == nil { - for _, release := range hist { - appVersion := fmt.Sprintf("App: %s", release.Chart.Metadata.AppVersion) - chartDesc := fmt.Sprintf("Chart: %s-%s", release.Chart.Metadata.Name, release.Chart.Metadata.Version) - revisions = append(revisions, fmt.Sprintf("%s\t%s, %s", strconv.Itoa(release.Version), appVersion, chartDesc)) + for _, rel := range hist { + appVersion := fmt.Sprintf("App: %s", rel.Chart.Metadata.AppVersion) + chartDesc := fmt.Sprintf("Chart: %s-%s", rel.Chart.Metadata.Name, rel.Chart.Metadata.Version) + revisions = append(revisions, fmt.Sprintf("%s\t%s, %s", strconv.Itoa(rel.Version), appVersion, chartDesc)) } return revisions, cobra.ShellCompDirectiveNoFileComp } diff --git a/cmd/helm/install.go b/cmd/helm/install.go index ed3f74274..da3498da3 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -129,7 +129,7 @@ charts in a repository, use 'helm search'. func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { client := action.NewInstall(cfg) valueOpts := &values.Options{} - var outfmt output.Format + var outFmt output.Format cmd := &cobra.Command{ Use: "install [NAME] [CHART]", @@ -141,14 +141,14 @@ func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, RunE: func(_ *cobra.Command, args []string) error { registryClient, err := newRegistryClient(client.CertFile, client.KeyFile, client.CaFile, - client.InsecureSkipTLSverify, client.PlainHTTP) + client.InsecureSkipTLSVerify, client.PlainHTTP) if err != nil { return fmt.Errorf("missing registry client: %w", err) } client.SetRegistryClient(registryClient) // This is for the case where "" is specifically passed in as a - // value. When there is no value passed in NoOptDefVal will be used + // value. When there is no value passed in NoOptDefVal will be used, // and it is set to client. See addInstallFlags. if client.DryRunOption == "" { client.DryRunOption = "none" @@ -158,16 +158,16 @@ func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { return errors.Wrap(err, "INSTALLATION FAILED") } - return outfmt.Write(out, &statusPrinter{rel, settings.Debug, false, false, false, client.HideNotes}) + return outFmt.Write(out, &statusPrinter{rel, settings.Debug, false, false, false, client.HideNotes}) }, } addInstallFlags(cmd, cmd.Flags(), client, valueOpts) - // hide-secret is not available in all places the install flags are used so + // the hide-secret is not available in all places where the install flags are used, so // it is added separately f := cmd.Flags() f.BoolVar(&client.HideSecret, "hide-secret", false, "hide Kubernetes Secrets when also using the --dry-run flag") - bindOutputFlag(cmd, &outfmt) + bindOutputFlag(cmd, &outFmt) bindPostRenderFlag(cmd, &client.PostRenderer) return cmd @@ -226,13 +226,13 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options client.Version = ">0.0.0-0" } - name, chart, err := client.NameAndChart(args) + name, chartName, err := client.NameAndChart(args) if err != nil { return nil, err } client.ReleaseName = name - cp, err := client.ChartPathOptions.LocateChart(chart, settings) + cp, err := client.ChartPathOptions.LocateChart(chartName, settings) if err != nil { return nil, err } @@ -308,7 +308,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options signal.Notify(cSignal, os.Interrupt, syscall.SIGTERM) go func() { <-cSignal - fmt.Fprintf(out, "Release %s has been cancelled.\n", args[0]) + _, _ = fmt.Fprintf(out, "Release %s has been cancelled.\n", args[0]) cancel() }() diff --git a/cmd/helm/lint.go b/cmd/helm/lint.go index 6b54bdd3f..7a2bbac02 100644 --- a/cmd/helm/lint.go +++ b/cmd/helm/lint.go @@ -67,7 +67,7 @@ func newLintCmd(out io.Writer) *cobra.Command { if client.WithSubcharts { for _, p := range paths { - filepath.Walk(filepath.Join(p, "charts"), func(path string, info os.FileInfo, _ error) error { + _ = filepath.Walk(filepath.Join(p, "charts"), func(path string, info os.FileInfo, _ error) error { if info != nil { if info.Name() == "Chart.yaml" { paths = append(paths, filepath.Dir(path)) @@ -103,7 +103,7 @@ func newLintCmd(out io.Writer) *cobra.Command { continue } - fmt.Fprintf(&message, "==> Linting %s\n", path) + _, _ = fmt.Fprintf(&message, "==> Linting %s\n", path) // All the Errors that are generated by a chart // that failed a lint will be included in the @@ -111,13 +111,13 @@ func newLintCmd(out io.Writer) *cobra.Command { // the Errors if there are no Messages. if len(result.Messages) == 0 { for _, err := range result.Errors { - fmt.Fprintf(&message, "Error %s\n", err) + _, _ = fmt.Fprintf(&message, "Error %s\n", err) } } for _, msg := range result.Messages { if !client.Quiet || msg.Severity > support.InfoSev { - fmt.Fprintf(&message, "%s\n", msg) + _, _ = fmt.Fprintf(&message, "%s\n", msg) } } @@ -128,17 +128,17 @@ func newLintCmd(out io.Writer) *cobra.Command { // Adding extra new line here to break up the // results, stops this from being a big wall of // text and makes it easier to follow. - fmt.Fprint(&message, "\n") + _, _ = fmt.Fprint(&message, "\n") } - fmt.Fprint(out, message.String()) + _, _ = fmt.Fprint(out, message.String()) summary := fmt.Sprintf("%d chart(s) linted, %d chart(s) failed", len(paths), failed) if failed > 0 { return errors.New(summary) } if !client.Quiet || errorsOrWarnings > 0 { - fmt.Fprintln(out, summary) + _, _ = fmt.Fprintln(out, summary) } return nil }, diff --git a/cmd/helm/list.go b/cmd/helm/list.go index 91922a66d..0d0919d2b 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -60,7 +60,7 @@ flag with the '--offset' flag allows you to page through results. func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { client := action.NewList(cfg) - var outfmt output.Format + var outFmt output.Format cmd := &cobra.Command{ Use: "list", @@ -92,20 +92,20 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { switch outputFlag.Value.String() { case "json": - output.EncodeJSON(out, names) + _ = output.EncodeJSON(out, names) return nil case "yaml": - output.EncodeYAML(out, names) + _ = output.EncodeYAML(out, names) return nil case "table": for _, res := range results { - fmt.Fprintln(out, res.Name) + _, _ = fmt.Fprintln(out, res.Name) } return nil } } - return outfmt.Write(out, newReleaseListWriter(results, client.TimeFormat, client.NoHeaders)) + return outFmt.Write(out, newReleaseListWriter(results, client.TimeFormat, client.NoHeaders)) }, } @@ -127,7 +127,7 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.IntVar(&client.Offset, "offset", 0, "next release index in the list, used to offset from start value") f.StringVarP(&client.Filter, "filter", "f", "", "a regular expression (Perl compatible). Any releases that match the expression will be included in the results") f.StringVarP(&client.Selector, "selector", "l", "", "Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2). Works only for secret(default) and configmap storage backends.") - bindOutputFlag(cmd, &outfmt) + bindOutputFlag(cmd, &outFmt) return cmd } @@ -156,7 +156,7 @@ func newReleaseListWriter(releases []*release.Release, timeFormat string, noHead Namespace: r.Namespace, Revision: strconv.Itoa(r.Version), Status: r.Info.Status.String(), - Chart: formatChartname(r.Chart), + Chart: formatChartName(r.Chart), AppVersion: formatAppVersion(r.Chart), } @@ -225,7 +225,7 @@ func compListReleases(toComplete string, ignoredReleaseNames []string, cfg *acti client := action.NewList(cfg) client.All = true client.Limit = 0 - // Do not filter so as to get the entire list of releases. + // Do not filter to get the entire list of releases. // This will allow zsh and fish to match completion choices // on other criteria then prefix. For example: // helm status ingress diff --git a/cmd/helm/load_plugins.go b/cmd/helm/load_plugins.go index 0fbf80d4f..43ccc847a 100644 --- a/cmd/helm/load_plugins.go +++ b/cmd/helm/load_plugins.go @@ -58,7 +58,7 @@ func loadPlugins(baseCmd *cobra.Command, out io.Writer) { found, err := plugin.FindPlugins(settings.PluginsDirectory) if err != nil { - fmt.Fprintf(os.Stderr, "failed to load plugins: %s\n", err) + _, _ = fmt.Fprintf(os.Stderr, "failed to load plugins: %s\n", err) return } diff --git a/cmd/helm/package.go b/cmd/helm/package.go index b96110ee8..bd2f0695f 100644 --- a/cmd/helm/package.go +++ b/cmd/helm/package.go @@ -104,7 +104,7 @@ func newPackageCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { if err != nil { return err } - fmt.Fprintf(out, "Successfully packaged chart and saved it to: %s\n", p) + _, _ = fmt.Fprintf(out, "Successfully packaged chart and saved it to: %s\n", p) } return nil }, diff --git a/cmd/helm/plugin_install.go b/cmd/helm/plugin_install.go index 9e3c399b5..a18da201e 100644 --- a/cmd/helm/plugin_install.go +++ b/cmd/helm/plugin_install.go @@ -89,6 +89,6 @@ func (o *pluginInstallOptions) run(out io.Writer) error { return err } - fmt.Fprintf(out, "Installed plugin: %s\n", p.Metadata.Name) + _, _ = fmt.Fprintf(out, "Installed plugin: %s\n", p.Metadata.Name) return nil } diff --git a/cmd/helm/plugin_list.go b/cmd/helm/plugin_list.go index ed17d9e6b..9fcb217af 100644 --- a/cmd/helm/plugin_list.go +++ b/cmd/helm/plugin_list.go @@ -43,7 +43,7 @@ func newPluginListCmd(out io.Writer) *cobra.Command { for _, p := range plugins { table.AddRow(p.Metadata.Name, p.Metadata.Version, p.Metadata.Description) } - fmt.Fprintln(out, table) + _, _ = fmt.Fprintln(out, table) return nil }, } @@ -58,16 +58,16 @@ func filterPlugins(plugins []*plugin.Plugin, ignoredPluginNames []string) []*plu } var filteredPlugins []*plugin.Plugin - for _, plugin := range plugins { + for _, plg := range plugins { found := false for _, ignoredName := range ignoredPluginNames { - if plugin.Metadata.Name == ignoredName { + if plg.Metadata.Name == ignoredName { found = true break } } if !found { - filteredPlugins = append(filteredPlugins, plugin) + filteredPlugins = append(filteredPlugins, plg) } } diff --git a/cmd/helm/plugin_uninstall.go b/cmd/helm/plugin_uninstall.go index 607baab2e..ac79b9c63 100644 --- a/cmd/helm/plugin_uninstall.go +++ b/cmd/helm/plugin_uninstall.go @@ -71,7 +71,7 @@ func (o *pluginUninstallOptions) run(out io.Writer) error { if err := uninstallPlugin(found); err != nil { errorPlugins = append(errorPlugins, fmt.Sprintf("Failed to uninstall plugin %s, got error (%v)", name, err)) } else { - fmt.Fprintf(out, "Uninstalled plugin: %s\n", name) + _, _ = fmt.Fprintf(out, "Uninstalled plugin: %s\n", name) } } else { errorPlugins = append(errorPlugins, fmt.Sprintf("Plugin: %s not found", name)) diff --git a/cmd/helm/plugin_update.go b/cmd/helm/plugin_update.go index 3f6d963fb..8595dffbf 100644 --- a/cmd/helm/plugin_update.go +++ b/cmd/helm/plugin_update.go @@ -74,7 +74,7 @@ func (o *pluginUpdateOptions) run(out io.Writer) error { if err := updatePlugin(found); err != nil { errorPlugins = append(errorPlugins, fmt.Sprintf("Failed to update plugin %s, got error (%v)", name, err)) } else { - fmt.Fprintf(out, "Updated plugin: %s\n", name) + _, _ = fmt.Fprintf(out, "Updated plugin: %s\n", name) } } else { errorPlugins = append(errorPlugins, fmt.Sprintf("Plugin: %s not found", name)) diff --git a/cmd/helm/pull.go b/cmd/helm/pull.go index e0dd1effe..e9dfd4a28 100644 --- a/cmd/helm/pull.go +++ b/cmd/helm/pull.go @@ -65,7 +65,7 @@ func newPullCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } registryClient, err := newRegistryClient(client.CertFile, client.KeyFile, client.CaFile, - client.InsecureSkipTLSverify, client.PlainHTTP) + client.InsecureSkipTLSVerify, client.PlainHTTP) if err != nil { return fmt.Errorf("missing registry client: %w", err) } @@ -76,7 +76,7 @@ func newPullCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { if err != nil { return err } - fmt.Fprint(out, output) + _, _ = fmt.Fprint(out, output) } return nil }, diff --git a/cmd/helm/push.go b/cmd/helm/push.go index f865c96bb..85a77acd4 100644 --- a/cmd/helm/push.go +++ b/cmd/helm/push.go @@ -38,7 +38,7 @@ type registryPushOptions struct { certFile string keyFile string caFile string - insecureSkipTLSverify bool + insecureSkipTLSVerify bool plainHTTP bool } @@ -68,7 +68,7 @@ func newPushCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { return nil, cobra.ShellCompDirectiveNoFileComp }, RunE: func(_ *cobra.Command, args []string) error { - registryClient, err := newRegistryClient(o.certFile, o.keyFile, o.caFile, o.insecureSkipTLSverify, o.plainHTTP) + registryClient, err := newRegistryClient(o.certFile, o.keyFile, o.caFile, o.insecureSkipTLSVerify, o.plainHTTP) if err != nil { return fmt.Errorf("missing registry client: %w", err) } @@ -77,7 +77,7 @@ func newPushCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { remote := args[1] client := action.NewPushWithOpts(action.WithPushConfig(cfg), action.WithTLSClientConfig(o.certFile, o.keyFile, o.caFile), - action.WithInsecureSkipTLSVerify(o.insecureSkipTLSverify), + action.WithInsecureSkipTLSVerify(o.insecureSkipTLSVerify), action.WithPlainHTTP(o.plainHTTP), action.WithPushOptWriter(out)) client.Settings = settings @@ -85,7 +85,7 @@ func newPushCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { if err != nil { return err } - fmt.Fprint(out, output) + _, _ = fmt.Fprint(out, output) return nil }, } @@ -94,7 +94,7 @@ func newPushCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.StringVar(&o.certFile, "cert-file", "", "identify registry client using this SSL certificate file") f.StringVar(&o.keyFile, "key-file", "", "identify registry client using this SSL key file") f.StringVar(&o.caFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle") - f.BoolVar(&o.insecureSkipTLSverify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the chart upload") + f.BoolVar(&o.insecureSkipTLSVerify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the chart upload") f.BoolVar(&o.plainHTTP, "plain-http", false, "use insecure HTTP connections for the chart upload") return cmd diff --git a/cmd/helm/release_testing.go b/cmd/helm/release_testing.go index 7a4be5732..3da4314e8 100644 --- a/cmd/helm/release_testing.go +++ b/cmd/helm/release_testing.go @@ -39,7 +39,7 @@ The tests to be run are defined in the chart that was installed. func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { client := action.NewReleaseTesting(cfg) - var outfmt = output.Table + var outFmt = output.Table var outputLogs bool var filter []string @@ -66,19 +66,19 @@ func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command } rel, runErr := client.Run(args[0]) // We only return an error if we weren't even able to get the - // release, otherwise we keep going so we can print status and logs + // release, otherwise we keep going, so we can print status and logs // if requested if runErr != nil && rel == nil { return runErr } - if err := outfmt.Write(out, &statusPrinter{rel, settings.Debug, false, false, false, client.HideNotes}); err != nil { + if err := outFmt.Write(out, &statusPrinter{rel, settings.Debug, false, false, false, client.HideNotes}); err != nil { return err } if outputLogs { // Print a newline to stdout to separate the output - fmt.Fprintln(out) + _, _ = fmt.Fprintln(out) if err := client.GetPodLogs(out, rel); err != nil { return err } diff --git a/cmd/helm/repo_add.go b/cmd/helm/repo_add.go index 83fcdf50c..fd664d455 100644 --- a/cmd/helm/repo_add.go +++ b/cmd/helm/repo_add.go @@ -55,7 +55,7 @@ type repoAddOptions struct { certFile string keyFile string caFile string - insecureSkipTLSverify bool + insecureSkipTLSVerify bool repoFile string repoCache string @@ -91,7 +91,7 @@ func newRepoAddCmd(out io.Writer) *cobra.Command { f.StringVar(&o.certFile, "cert-file", "", "identify HTTPS client using this SSL certificate file") f.StringVar(&o.keyFile, "key-file", "", "identify HTTPS client using this SSL key file") f.StringVar(&o.caFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle") - f.BoolVar(&o.insecureSkipTLSverify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the repository") + f.BoolVar(&o.insecureSkipTLSVerify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the repository") f.BoolVar(&o.allowDeprecatedRepos, "allow-deprecated-repos", false, "by default, this command will not allow adding official repos that have been permanently deleted. This disables that behavior") f.BoolVar(&o.passCredentialsAll, "pass-credentials", false, "pass credentials to all domains") @@ -154,9 +154,9 @@ func (o *repoAddOptions) run(out io.Writer) error { o.password = password } else { fd := int(os.Stdin.Fd()) - fmt.Fprint(out, "Password: ") + _, _ = fmt.Fprint(out, "Password: ") password, err := term.ReadPassword(fd) - fmt.Fprintln(out) + _, _ = fmt.Fprintln(out) if err != nil { return err } @@ -173,7 +173,7 @@ func (o *repoAddOptions) run(out io.Writer) error { CertFile: o.certFile, KeyFile: o.keyFile, CAFile: o.caFile, - InsecureSkipTLSverify: o.insecureSkipTLSverify, + InsecureSkipTLSverify: o.insecureSkipTLSVerify, } // Check if the repo name is legal @@ -194,7 +194,7 @@ func (o *repoAddOptions) run(out io.Writer) error { } // The add is idempotent so do nothing - fmt.Fprintf(out, "%q already exists with the same configuration, skipping\n", o.name) + _, _ = fmt.Fprintf(out, "%q already exists with the same configuration, skipping\n", o.name) return nil } @@ -215,6 +215,6 @@ func (o *repoAddOptions) run(out io.Writer) error { if err := f.WriteFile(o.repoFile, 0600); err != nil { return err } - fmt.Fprintf(out, "%q has been added to your repositories\n", o.name) + _, _ = fmt.Fprintf(out, "%q has been added to your repositories\n", o.name) return nil } diff --git a/cmd/helm/repo_list.go b/cmd/helm/repo_list.go index 8abd20654..6db669ab7 100644 --- a/cmd/helm/repo_list.go +++ b/cmd/helm/repo_list.go @@ -30,7 +30,7 @@ import ( ) func newRepoListCmd(out io.Writer) *cobra.Command { - var outfmt output.Format + var outFmt output.Format cmd := &cobra.Command{ Use: "list", Aliases: []string{"ls"}, @@ -39,15 +39,15 @@ func newRepoListCmd(out io.Writer) *cobra.Command { ValidArgsFunction: noCompletions, RunE: func(_ *cobra.Command, _ []string) error { f, _ := repo.LoadFile(settings.RepositoryConfig) - if len(f.Repositories) == 0 && !(outfmt == output.JSON || outfmt == output.YAML) { + if len(f.Repositories) == 0 && !(outFmt == output.JSON || outFmt == output.YAML) { return errors.New("no repositories to show") } - return outfmt.Write(out, &repoListWriter{f.Repositories}) + return outFmt.Write(out, &repoListWriter{f.Repositories}) }, } - bindOutputFlag(cmd, &outfmt) + bindOutputFlag(cmd, &outFmt) return cmd } @@ -80,17 +80,17 @@ func (r *repoListWriter) WriteYAML(out io.Writer) error { func (r *repoListWriter) encodeByFormat(out io.Writer, format output.Format) error { // Initialize the array so no results returns an empty array instead of null - repolist := make([]repositoryElement, 0, len(r.repos)) + repoList := make([]repositoryElement, 0, len(r.repos)) for _, re := range r.repos { - repolist = append(repolist, repositoryElement{Name: re.Name, URL: re.URL}) + repoList = append(repoList, repositoryElement{Name: re.Name, URL: re.URL}) } switch format { case output.JSON: - return output.EncodeJSON(out, repolist) + return output.EncodeJSON(out, repoList) case output.YAML: - return output.EncodeYAML(out, repolist) + return output.EncodeYAML(out, repoList) } // Because this is a non-exported function and only called internally by @@ -113,9 +113,9 @@ func filterRepos(repos []*repo.Entry, ignoredRepoNames []string) []*repo.Entry { ignored[repoName] = true } - for _, repo := range repos { - if _, removed := ignored[repo.Name]; !removed { - filteredRepos = append(filteredRepos, repo) + for _, rp := range repos { + if _, removed := ignored[rp.Name]; !removed { + filteredRepos = append(filteredRepos, rp) } } @@ -129,8 +129,8 @@ func compListRepos(_ string, ignoredRepoNames []string) []string { f, err := repo.LoadFile(settings.RepositoryConfig) if err == nil && len(f.Repositories) > 0 { filteredRepos := filterRepos(f.Repositories, ignoredRepoNames) - for _, repo := range filteredRepos { - rNames = append(rNames, fmt.Sprintf("%s\t%s", repo.Name, repo.URL)) + for _, rp := range filteredRepos { + rNames = append(rNames, fmt.Sprintf("%s\t%s", rp.Name, rp.URL)) } } return rNames diff --git a/cmd/helm/repo_remove.go b/cmd/helm/repo_remove.go index 82a235fec..17efe88b8 100644 --- a/cmd/helm/repo_remove.go +++ b/cmd/helm/repo_remove.go @@ -74,7 +74,7 @@ func (o *repoRemoveOptions) run(out io.Writer) error { if err := removeRepoCache(o.repoCache, name); err != nil { return err } - fmt.Fprintf(out, "%q has been removed from your repositories\n", name) + _, _ = fmt.Fprintf(out, "%q has been removed from your repositories\n", name) } return nil @@ -83,7 +83,7 @@ func (o *repoRemoveOptions) run(out io.Writer) error { func removeRepoCache(root, name string) error { idx := filepath.Join(root, helmpath.CacheChartsFile(name)) if _, err := os.Stat(idx); err == nil { - os.Remove(idx) + _ = os.Remove(idx) } idx = filepath.Join(root, helmpath.CacheIndexFile(name)) diff --git a/cmd/helm/repo_update.go b/cmd/helm/repo_update.go index 8d5f532f1..90811c3b6 100644 --- a/cmd/helm/repo_update.go +++ b/cmd/helm/repo_update.go @@ -115,7 +115,7 @@ func (o *repoUpdateOptions) run(out io.Writer) error { } func updateCharts(repos []*repo.ChartRepository, out io.Writer, failOnRepoUpdateFail bool) error { - fmt.Fprintln(out, "Hang tight while we grab the latest from your chart repositories...") + _, _ = fmt.Fprintln(out, "Hang tight while we grab the latest from your chart repositories...") var wg sync.WaitGroup var repoFailList []string for _, re := range repos { @@ -123,29 +123,29 @@ func updateCharts(repos []*repo.ChartRepository, out io.Writer, failOnRepoUpdate go func(re *repo.ChartRepository) { defer wg.Done() if _, err := re.DownloadIndexFile(); err != nil { - fmt.Fprintf(out, "...Unable to get an update from the %q chart repository (%s):\n\t%s\n", re.Config.Name, re.Config.URL, err) + _, _ = fmt.Fprintf(out, "...Unable to get an update from the %q chart repository (%s):\n\t%s\n", re.Config.Name, re.Config.URL, err) repoFailList = append(repoFailList, re.Config.URL) } else { - fmt.Fprintf(out, "...Successfully got an update from the %q chart repository\n", re.Config.Name) + _, _ = fmt.Fprintf(out, "...Successfully got an update from the %q chart repository\n", re.Config.Name) } }(re) } wg.Wait() if len(repoFailList) > 0 && failOnRepoUpdateFail { - return fmt.Errorf("Failed to update the following repositories: %s", + return fmt.Errorf("failed to update the following repositories: %s", repoFailList) } - fmt.Fprintln(out, "Update Complete. ⎈Happy Helming!⎈") + _, _ = fmt.Fprintln(out, "Update Complete. ⎈Happy Helming!⎈") return nil } func checkRequestedRepos(requestedRepos []string, validRepos []*repo.Entry) error { for _, requestedRepo := range requestedRepos { found := false - for _, repo := range validRepos { - if requestedRepo == repo.Name { + for _, validRepo := range validRepos { + if requestedRepo == validRepo.Name { found = true break } diff --git a/cmd/helm/repo_update_test.go b/cmd/helm/repo_update_test.go index 1ddf0f5ed..aea2e1a53 100644 --- a/cmd/helm/repo_update_test.go +++ b/cmd/helm/repo_update_test.go @@ -36,7 +36,7 @@ func TestUpdateCmd(t *testing.T) { // The TestUpdateCharts test verifies the HTTP behavior independently. updater := func(repos []*repo.ChartRepository, out io.Writer, _ bool) error { for _, re := range repos { - fmt.Fprintln(out, re.Config.Name) + _, _ = fmt.Fprintln(out, re.Config.Name) } return nil } @@ -61,7 +61,7 @@ func TestUpdateCmdMultiple(t *testing.T) { // The TestUpdateCharts test verifies the HTTP behavior independently. updater := func(repos []*repo.ChartRepository, out io.Writer, _ bool) error { for _, re := range repos { - fmt.Fprintln(out, re.Config.Name) + _, _ = fmt.Fprintln(out, re.Config.Name) } return nil } @@ -87,7 +87,7 @@ func TestUpdateCmdInvalid(t *testing.T) { // The TestUpdateCharts test verifies the HTTP behavior independently. updater := func(repos []*repo.ChartRepository, out io.Writer, _ bool) error { for _, re := range repos { - fmt.Fprintln(out, re.Config.Name) + _, _ = fmt.Fprintln(out, re.Config.Name) } return nil } @@ -104,7 +104,10 @@ func TestUpdateCmdInvalid(t *testing.T) { func TestUpdateCustomCacheCmd(t *testing.T) { rootDir := t.TempDir() cachePath := filepath.Join(rootDir, "updcustomcache") - os.Mkdir(cachePath, os.ModePerm) + err := os.Mkdir(cachePath, os.ModePerm) + if err != nil { + t.Fatalf("error creating custom cache directory: %v", err) + } ts, err := repotest.NewTempServerWithCleanup(t, "testdata/testserver/*.*") if err != nil { @@ -145,7 +148,7 @@ func TestUpdateCharts(t *testing.T) { } b := bytes.NewBuffer(nil) - updateCharts([]*repo.ChartRepository{r}, b, false) + _ = updateCharts([]*repo.ChartRepository{r}, b, false) got := b.String() if strings.Contains(got, "Unable to get an update") { diff --git a/cmd/helm/rollback.go b/cmd/helm/rollback.go index 7e4c721f5..bcc891d87 100644 --- a/cmd/helm/rollback.go +++ b/cmd/helm/rollback.go @@ -70,7 +70,7 @@ func newRollbackCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { return err } - fmt.Fprintf(out, "Rollback was a success! Happy Helming!\n") + _, _ = fmt.Fprintf(out, "Rollback was a success! Happy Helming!\n") return nil }, } diff --git a/cmd/helm/root.go b/cmd/helm/root.go index c5f8cc708..251a939e0 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -134,8 +134,8 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string loadingRules, &clientcmd.ConfigOverrides{}).RawConfig(); err == nil { comps := []string{} - for name, context := range config.Contexts { - comps = append(comps, fmt.Sprintf("%s\t%s", name, context.Cluster)) + for name, ctx := range config.Contexts { + comps = append(comps, fmt.Sprintf("%s\t%s", name, ctx.Cluster)) } return comps, cobra.ShellCompDirectiveNoFileComp } @@ -151,7 +151,7 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string // This call is required to gather configuration information prior to // execution. flags.ParseErrorsWhitelist.UnknownFlags = true - flags.Parse(args) + _ = flags.Parse(args) registryClient, err := newDefaultRegistryClient(false) if err != nil { @@ -210,7 +210,7 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string return cmd, nil } -func checkForExpiredRepos(repofile string) { +func checkForExpiredRepos(repoPath string) { expiredRepos := []struct { name string @@ -232,7 +232,7 @@ func checkForExpiredRepos(repofile string) { // parse repo file. // Ignore the error because it is okay for a repo file to be unparseable at this // stage. Later checks will trap the error and respond accordingly. - repoFile, err := repo.LoadFile(repofile) + repoFile, err := repo.LoadFile(repoPath) if err != nil { return } @@ -244,7 +244,7 @@ func checkForExpiredRepos(repofile string) { } if url := r.URL; strings.Contains(url, exp.old) { - fmt.Fprintf( + _, _ = fmt.Fprintf( os.Stderr, "WARNING: %q is deprecated for %q and will be deleted Nov. 13, 2020.\nWARNING: You should switch to %q via:\nWARNING: helm repo add %q %q --force-update\n", exp.old, @@ -258,9 +258,9 @@ func checkForExpiredRepos(repofile string) { } -func newRegistryClient(certFile, keyFile, caFile string, insecureSkipTLSverify, plainHTTP bool) (*registry.Client, error) { - if certFile != "" && keyFile != "" || caFile != "" || insecureSkipTLSverify { - registryClient, err := newRegistryClientWithTLS(certFile, keyFile, caFile, insecureSkipTLSverify) +func newRegistryClient(certFile, keyFile, caFile string, insecureSkipTLSVerify, plainHTTP bool) (*registry.Client, error) { + if certFile != "" && keyFile != "" || caFile != "" || insecureSkipTLSVerify { + registryClient, err := newRegistryClientWithTLS(certFile, keyFile, caFile, insecureSkipTLSVerify) if err != nil { return nil, err } @@ -292,9 +292,9 @@ func newDefaultRegistryClient(plainHTTP bool) (*registry.Client, error) { return registryClient, nil } -func newRegistryClientWithTLS(certFile, keyFile, caFile string, insecureSkipTLSverify bool) (*registry.Client, error) { +func newRegistryClientWithTLS(certFile, keyFile, caFile string, insecureSkipTLSVerify bool) (*registry.Client, error) { // Create a new registry client - registryClient, err := registry.NewRegistryClientWithTLS(os.Stderr, certFile, keyFile, caFile, insecureSkipTLSverify, + registryClient, err := registry.NewRegistryClientWithTLS(os.Stderr, certFile, keyFile, caFile, insecureSkipTLSVerify, settings.RegistryConfig, settings.Debug, ) if err != nil { diff --git a/cmd/helm/search_hub_test.go b/cmd/helm/search_hub_test.go index f3730275a..2da54cf64 100644 --- a/cmd/helm/search_hub_test.go +++ b/cmd/helm/search_hub_test.go @@ -25,10 +25,10 @@ import ( func TestSearchHubCmd(t *testing.T) { - // Setup a mock search service + // Set up a mock search service var searchResult = `{"data":[{"id":"stable/phpmyadmin","type":"chart","attributes":{"name":"phpmyadmin","repo":{"name":"stable","url":"https://charts.helm.sh/stable"},"description":"phpMyAdmin is an mysql administration frontend","home":"https://www.phpmyadmin.net/","keywords":["mariadb","mysql","phpmyadmin"],"maintainers":[{"name":"Bitnami","email":"containers@bitnami.com"}],"sources":["https://github.com/bitnami/bitnami-docker-phpmyadmin"],"icon":""},"links":{"self":"/v1/charts/stable/phpmyadmin"},"relationships":{"latestChartVersion":{"data":{"version":"3.0.0","app_version":"4.9.0-1","created":"2019-08-08T17:57:31.38Z","digest":"119c499251bffd4b06ff0cd5ac98c2ce32231f84899fb4825be6c2d90971c742","urls":["https://charts.helm.sh/stable/phpmyadmin-3.0.0.tgz"],"readme":"/v1/assets/stable/phpmyadmin/versions/3.0.0/README.md","values":"/v1/assets/stable/phpmyadmin/versions/3.0.0/values.yaml"},"links":{"self":"/v1/charts/stable/phpmyadmin/versions/3.0.0"}}}},{"id":"bitnami/phpmyadmin","type":"chart","attributes":{"name":"phpmyadmin","repo":{"name":"bitnami","url":"https://charts.bitnami.com"},"description":"phpMyAdmin is an mysql administration frontend","home":"https://www.phpmyadmin.net/","keywords":["mariadb","mysql","phpmyadmin"],"maintainers":[{"name":"Bitnami","email":"containers@bitnami.com"}],"sources":["https://github.com/bitnami/bitnami-docker-phpmyadmin"],"icon":""},"links":{"self":"/v1/charts/bitnami/phpmyadmin"},"relationships":{"latestChartVersion":{"data":{"version":"3.0.0","app_version":"4.9.0-1","created":"2019-08-08T18:34:13.341Z","digest":"66d77cf6d8c2b52c488d0a294cd4996bd5bad8dc41d3829c394498fb401c008a","urls":["https://charts.bitnami.com/bitnami/phpmyadmin-3.0.0.tgz"],"readme":"/v1/assets/bitnami/phpmyadmin/versions/3.0.0/README.md","values":"/v1/assets/bitnami/phpmyadmin/versions/3.0.0/values.yaml"},"links":{"self":"/v1/charts/bitnami/phpmyadmin/versions/3.0.0"}}}}]}` ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { - fmt.Fprintln(w, searchResult) + _, _ = fmt.Fprintln(w, searchResult) })) defer ts.Close() @@ -55,10 +55,10 @@ func TestSearchHubCmd(t *testing.T) { func TestSearchHubListRepoCmd(t *testing.T) { - // Setup a mock search service + // Set up a mock search service var searchResult = `{"data":[{"id":"stable/phpmyadmin","type":"chart","attributes":{"name":"phpmyadmin","repo":{"name":"stable","url":"https://charts.helm.sh/stable"},"description":"phpMyAdmin is an mysql administration frontend","home":"https://www.phpmyadmin.net/","keywords":["mariadb","mysql","phpmyadmin"],"maintainers":[{"name":"Bitnami","email":"containers@bitnami.com"}],"sources":["https://github.com/bitnami/bitnami-docker-phpmyadmin"],"icon":""},"links":{"self":"/v1/charts/stable/phpmyadmin"},"relationships":{"latestChartVersion":{"data":{"version":"3.0.0","app_version":"4.9.0-1","created":"2019-08-08T17:57:31.38Z","digest":"119c499251bffd4b06ff0cd5ac98c2ce32231f84899fb4825be6c2d90971c742","urls":["https://charts.helm.sh/stable/phpmyadmin-3.0.0.tgz"],"readme":"/v1/assets/stable/phpmyadmin/versions/3.0.0/README.md","values":"/v1/assets/stable/phpmyadmin/versions/3.0.0/values.yaml"},"links":{"self":"/v1/charts/stable/phpmyadmin/versions/3.0.0"}}}},{"id":"bitnami/phpmyadmin","type":"chart","attributes":{"name":"phpmyadmin","repo":{"name":"bitnami","url":"https://charts.bitnami.com"},"description":"phpMyAdmin is an mysql administration frontend","home":"https://www.phpmyadmin.net/","keywords":["mariadb","mysql","phpmyadmin"],"maintainers":[{"name":"Bitnami","email":"containers@bitnami.com"}],"sources":["https://github.com/bitnami/bitnami-docker-phpmyadmin"],"icon":""},"links":{"self":"/v1/charts/bitnami/phpmyadmin"},"relationships":{"latestChartVersion":{"data":{"version":"3.0.0","app_version":"4.9.0-1","created":"2019-08-08T18:34:13.341Z","digest":"66d77cf6d8c2b52c488d0a294cd4996bd5bad8dc41d3829c394498fb401c008a","urls":["https://charts.bitnami.com/bitnami/phpmyadmin-3.0.0.tgz"],"readme":"/v1/assets/bitnami/phpmyadmin/versions/3.0.0/README.md","values":"/v1/assets/bitnami/phpmyadmin/versions/3.0.0/values.yaml"},"links":{"self":"/v1/charts/bitnami/phpmyadmin/versions/3.0.0"}}}}]}` ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { - fmt.Fprintln(w, searchResult) + _, _ = fmt.Fprintln(w, searchResult) })) defer ts.Close() @@ -154,9 +154,9 @@ func TestSearchHubCmd_FailOnNoResponseTests(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - // Setup a mock search service + // Set up a mock search service ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { - fmt.Fprintln(w, tt.response) + _, _ = fmt.Fprintln(w, tt.response) })) defer ts.Close() diff --git a/cmd/helm/show.go b/cmd/helm/show.go index 6b67dcdf4..32067f403 100644 --- a/cmd/helm/show.go +++ b/cmd/helm/show.go @@ -92,7 +92,7 @@ func newShowCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { if err != nil { return err } - fmt.Fprint(out, output) + _, _ = fmt.Fprint(out, output) return nil }, } @@ -113,7 +113,7 @@ func newShowCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { if err != nil { return err } - fmt.Fprint(out, output) + _, _ = fmt.Fprint(out, output) return nil }, } @@ -134,7 +134,7 @@ func newShowCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { if err != nil { return err } - fmt.Fprint(out, output) + _, _ = fmt.Fprint(out, output) return nil }, } @@ -155,7 +155,7 @@ func newShowCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { if err != nil { return err } - fmt.Fprint(out, output) + _, _ = fmt.Fprint(out, output) return nil }, } @@ -176,7 +176,7 @@ func newShowCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { if err != nil { return err } - fmt.Fprint(out, output) + _, _ = fmt.Fprint(out, output) return nil }, } @@ -227,7 +227,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, - client.InsecureSkipTLSverify, client.PlainHTTP) + client.InsecureSkipTLSVerify, client.PlainHTTP) if err != nil { return fmt.Errorf("missing registry client: %w", err) } diff --git a/cmd/helm/status.go b/cmd/helm/status.go index 206c2d8cc..9eb4c61a3 100644 --- a/cmd/helm/status.go +++ b/cmd/helm/status.go @@ -51,7 +51,7 @@ The status consists of: func newStatusCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { client := action.NewStatus(cfg) - var outfmt output.Format + var outFmt output.Format cmd := &cobra.Command{ Use: "status RELEASE_NAME", @@ -69,7 +69,7 @@ func newStatusCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { // When the output format is a table the resources should be fetched // and displayed as a table. When YAML or JSON the resources will be // returned. This mirrors the handling in kubectl. - if outfmt == output.Table { + if outFmt == output.Table { client.ShowResourcesTable = true } rel, err := client.Run(args[0]) @@ -80,7 +80,7 @@ func newStatusCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { // strip chart metadata from the output rel.Chart = nil - return outfmt.Write(out, &statusPrinter{rel, false, client.ShowDescription, client.ShowResources, false, false}) + return outFmt.Write(out, &statusPrinter{rel, false, client.ShowDescription, client.ShowResources, false, false}) }, } @@ -99,7 +99,7 @@ func newStatusCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { log.Fatal(err) } - bindOutputFlag(cmd, &outfmt) + bindOutputFlag(cmd, &outFmt) f.BoolVar(&client.ShowDescription, "show-desc", false, "if set, display the description message of the named release") f.BoolVar(&client.ShowResources, "show-resources", false, "if set, display the resources of the named release") @@ -222,7 +222,7 @@ func (s statusPrinter) WriteTable(out io.Writer) error { // Hide notes from output - option in install and upgrades if !s.hideNotes && len(s.release.Info.Notes) > 0 { - fmt.Fprintf(out, "NOTES:\n%s\n", strings.TrimSpace(s.release.Info.Notes)) + _, _ = fmt.Fprintf(out, "NOTES:\n%s\n", strings.TrimSpace(s.release.Info.Notes)) } return nil } diff --git a/cmd/helm/template.go b/cmd/helm/template.go index b53ed6b1c..cfb70b3c2 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -74,7 +74,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } registryClient, err := newRegistryClient(client.CertFile, client.KeyFile, client.CaFile, - client.InsecureSkipTLSverify, client.PlainHTTP) + client.InsecureSkipTLSVerify, client.PlainHTTP) if err != nil { return fmt.Errorf("missing registry client: %w", err) } @@ -105,7 +105,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { // we always want to print the YAML, even if it is not valid. The error is still returned afterwards. if rel != nil { var manifests bytes.Buffer - fmt.Fprintln(&manifests, strings.TrimSpace(rel.Manifest)) + _, _ = fmt.Fprintln(&manifests, strings.TrimSpace(rel.Manifest)) if !client.DisableHooks { fileWritten := make(map[string]bool) for _, m := range rel.Hooks { @@ -113,7 +113,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { continue } if client.OutputDir == "" { - fmt.Fprintf(&manifests, "---\n# Source: %s\n%s\n", m.Path, m.Manifest) + _, _ = fmt.Fprintf(&manifests, "---\n# Source: %s\n%s\n", m.Path, m.Manifest) } else { newDir := client.OutputDir if client.UseReleaseName { @@ -178,10 +178,10 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } } for _, m := range manifestsToRender { - fmt.Fprintf(out, "---\n%s\n", m) + _, _ = fmt.Fprintf(out, "---\n%s\n", m) } } else { - fmt.Fprintf(out, "%s", manifests.String()) + _, _ = fmt.Fprintf(out, "%s", manifests.String()) } } diff --git a/cmd/helm/uninstall.go b/cmd/helm/uninstall.go index 3c4517b50..c3d6f699d 100644 --- a/cmd/helm/uninstall.go +++ b/cmd/helm/uninstall.go @@ -62,10 +62,10 @@ func newUninstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { return err } if res != nil && res.Info != "" { - fmt.Fprintln(out, res.Info) + _, _ = fmt.Fprintln(out, res.Info) } - fmt.Fprintf(out, "release \"%s\" uninstalled\n", args[i]) + _, _ = fmt.Fprintf(out, "release \"%s\" uninstalled\n", args[i]) } return nil }, diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index 23472619d..b2b7b90b9 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -82,7 +82,7 @@ which can contain sensitive values. To hide Kubernetes Secrets use the func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { client := action.NewUpgrade(cfg) valueOpts := &values.Options{} - var outfmt output.Format + var outFmt output.Format var createNamespace bool cmd := &cobra.Command{ @@ -103,14 +103,14 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { client.Namespace = settings.Namespace() registryClient, err := newRegistryClient(client.CertFile, client.KeyFile, client.CaFile, - client.InsecureSkipTLSverify, client.PlainHTTP) + client.InsecureSkipTLSVerify, client.PlainHTTP) if err != nil { return fmt.Errorf("missing registry client: %w", err) } client.SetRegistryClient(registryClient) // This is for the case where "" is specifically passed in as a - // value. When there is no value passed in NoOptDefVal will be used + // value. When there is no value passed in NoOptDefVal will be used, // and it is set to client. See addInstallFlags. if client.DryRunOption == "" { client.DryRunOption = "none" @@ -122,10 +122,10 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { histClient := action.NewHistory(cfg) histClient.Max = 1 versions, err := histClient.Run(args[0]) - if err == driver.ErrReleaseNotFound || isReleaseUninstalled(versions) { + if errors.Is(err, driver.ErrReleaseNotFound) || isReleaseUninstalled(versions) { // Only print this to stdout for table output - if outfmt == output.Table { - fmt.Fprintf(out, "Release %q does not exist. Installing it now.\n", args[0]) + if outFmt == output.Table { + _, _ = fmt.Fprintf(out, "Release %q does not exist. Installing it now.\n", args[0]) } instClient := action.NewInstall(cfg) instClient.CreateNamespace = createNamespace @@ -159,7 +159,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { if err != nil { return err } - return outfmt.Write(out, &statusPrinter{rel, settings.Debug, false, false, false, instClient.HideNotes}) + return outFmt.Write(out, &statusPrinter{rel, settings.Debug, false, false, false, instClient.HideNotes}) } else if err != nil { return err } @@ -232,7 +232,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { signal.Notify(cSignal, os.Interrupt, syscall.SIGTERM) go func() { <-cSignal - fmt.Fprintf(out, "Release %s has been cancelled.\n", args[0]) + _, _ = fmt.Fprintf(out, "Release %s has been cancelled.\n", args[0]) cancel() }() @@ -242,11 +242,11 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { return errors.Wrap(err, "UPGRADE FAILED") } - if outfmt == output.Table { - fmt.Fprintf(out, "Release %q has been upgraded. Happy Helming!\n", args[0]) + if outFmt == output.Table { + _, _ = fmt.Fprintf(out, "Release %q has been upgraded. Happy Helming!\n", args[0]) } - return outfmt.Write(out, &statusPrinter{rel, settings.Debug, false, false, false, client.HideNotes}) + return outFmt.Write(out, &statusPrinter{rel, settings.Debug, false, false, false, client.HideNotes}) }, } @@ -258,7 +258,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.BoolVar(&client.HideSecret, "hide-secret", false, "hide Kubernetes Secrets when also using the --dry-run flag") f.Lookup("dry-run").NoOptDefVal = "client" f.BoolVar(&client.Recreate, "recreate-pods", false, "performs pods restart for the resource if applicable") - f.MarkDeprecated("recreate-pods", "functionality will no longer be updated. Consult the documentation for other methods to recreate pods") + _ = f.MarkDeprecated("recreate-pods", "functionality will no longer be updated. Consult the documentation for other methods to recreate pods") f.BoolVar(&client.Force, "force", false, "force resource updates through a replacement strategy") f.BoolVar(&client.DisableHooks, "no-hooks", false, "disable pre/post upgrade hooks") f.BoolVar(&client.DisableOpenAPIValidation, "disable-openapi-validation", false, "if set, the upgrade process will not validate rendered templates against the Kubernetes OpenAPI Schema") @@ -280,7 +280,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { f.BoolVar(&client.EnableDNS, "enable-dns", false, "enable DNS lookups when rendering templates") addChartPathOptionsFlags(f, &client.ChartPathOptions) addValueOptionsFlags(f, valueOpts) - bindOutputFlag(cmd, &outfmt) + bindOutputFlag(cmd, &outFmt) bindPostRenderFlag(cmd, &client.PostRenderer) err := cmd.RegisterFlagCompletionFunc("version", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { diff --git a/cmd/helm/verify.go b/cmd/helm/verify.go index f667a31e9..65a632aad 100644 --- a/cmd/helm/verify.go +++ b/cmd/helm/verify.go @@ -58,7 +58,7 @@ func newVerifyCmd(out io.Writer) *cobra.Command { return err } - fmt.Fprint(out, client.Out) + _, _ = fmt.Fprint(out, client.Out) return nil }, diff --git a/cmd/helm/version.go b/cmd/helm/version.go index 409fc6fd9..24cacbd64 100644 --- a/cmd/helm/version.go +++ b/cmd/helm/version.go @@ -74,7 +74,7 @@ func newVersionCmd(out io.Writer) *cobra.Command { f.BoolVar(&o.short, "short", false, "print the version number") f.StringVar(&o.template, "template", "", "template for version string format") f.BoolP("client", "c", true, "display client version information") - f.MarkHidden("client") + _ = f.MarkHidden("client") return cmd } @@ -87,7 +87,7 @@ func (o *versionOptions) run(out io.Writer) error { } return tt.Execute(out, version.Get()) } - fmt.Fprintln(out, formatVersion(o.short)) + _, _ = fmt.Fprintln(out, formatVersion(o.short)) return nil } diff --git a/internal/monocular/search_test.go b/internal/monocular/search_test.go index fc82ef4b4..9f88ec490 100644 --- a/internal/monocular/search_test.go +++ b/internal/monocular/search_test.go @@ -29,7 +29,7 @@ var searchResult = `{"data":[{"id":"stable/phpmyadmin","type":"chart","attribute func TestSearch(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { - fmt.Fprintln(w, searchResult) + _, _ = fmt.Fprintln(w, searchResult) })) defer ts.Close() diff --git a/pkg/action/action.go b/pkg/action/action.go index 863c48f07..8be6c77b5 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -176,7 +176,7 @@ func (cfg *Configuration) renderResources(ch *chart.Chart, values chartutil.Valu if strings.TrimSpace(content) == "" { continue } - fmt.Fprintf(b, "---\n# Source: %s\n%s\n", name, content) + _, _ = fmt.Fprintf(b, "---\n# Source: %s\n%s\n", name, content) } return hs, b, "", err } @@ -187,7 +187,7 @@ func (cfg *Configuration) renderResources(ch *chart.Chart, values chartutil.Valu if includeCrds { for _, crd := range ch.CRDObjects() { if outputDir == "" { - fmt.Fprintf(b, "---\n# Source: %s\n%s\n", crd.Filename, string(crd.File.Data[:])) + _, _ = fmt.Fprintf(b, "---\n# Source: %s\n%s\n", crd.Filename, string(crd.File.Data[:])) } else { err = writeToFile(outputDir, crd.Filename, string(crd.File.Data[:]), fileWritten[crd.Filename]) if err != nil { @@ -201,9 +201,9 @@ func (cfg *Configuration) renderResources(ch *chart.Chart, values chartutil.Valu for _, m := range manifests { if outputDir == "" { if hideSecret && m.Head.Kind == "Secret" && m.Head.Version == "v1" { - fmt.Fprintf(b, "---\n# Source: %s\n# HIDDEN: The Secret output has been suppressed\n", m.Name) + _, _ = fmt.Fprintf(b, "---\n# Source: %s\n# HIDDEN: The Secret output has been suppressed\n", m.Name) } else { - fmt.Fprintf(b, "---\n# Source: %s\n%s\n", m.Name, m.Content) + _, _ = fmt.Fprintf(b, "---\n# Source: %s\n%s\n", m.Name, m.Content) } } else { newDir := outputDir @@ -359,7 +359,7 @@ func GetVersionSet(client discovery.ServerResourcesInterface) (chartutil.Version versions = append(versions, k) } - return chartutil.VersionSet(versions), nil + return versions, nil } // recordRelease with an update operation in case reuse has been set. @@ -374,7 +374,7 @@ func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namesp kc := kube.New(getter) kc.Log = log - lazyClient := &lazyClient{ + lazyCli := &lazyClient{ namespace: namespace, clientFn: kc.Factory.KubernetesClientSet, } @@ -382,11 +382,11 @@ func (cfg *Configuration) Init(getter genericclioptions.RESTClientGetter, namesp var store *storage.Storage switch helmDriver { case "secret", "secrets", "": - d := driver.NewSecrets(newSecretClient(lazyClient)) + d := driver.NewSecrets(newSecretClient(lazyCli)) d.Log = log store = storage.Init(d) case "configmap", "configmaps": - d := driver.NewConfigMaps(newConfigMapClient(lazyClient)) + d := driver.NewConfigMaps(newConfigMapClient(lazyCli)) d.Log = log store = storage.Init(d) case "memory": diff --git a/pkg/action/dependency.go b/pkg/action/dependency.go index 3265f1f17..d17dc7f3c 100644 --- a/pkg/action/dependency.go +++ b/pkg/action/dependency.go @@ -55,12 +55,12 @@ func (d *Dependency) List(chartpath string, out io.Writer) error { } if c.Metadata.Dependencies == nil { - fmt.Fprintf(out, "WARNING: no dependencies at %s\n", filepath.Join(chartpath, "charts")) + _, _ = fmt.Fprintf(out, "WARNING: no dependencies at %s\n", filepath.Join(chartpath, "charts")) return nil } d.printDependencies(chartpath, out, c) - fmt.Fprintln(out) + _, _ = fmt.Fprintln(out) d.printMissing(chartpath, out, c.Metadata.Dependencies) return nil } @@ -189,7 +189,7 @@ func (d *Dependency) printDependencies(chartpath string, out io.Writer, c *chart for _, row := range c.Metadata.Dependencies { table.AddRow(row.Name, row.Version, row.Repository, d.dependencyStatus(chartpath, row, c)) } - fmt.Fprintln(out, table) + _, _ = fmt.Fprintln(out, table) } // printMissing prints warnings about charts that are present on disk, but are @@ -198,14 +198,14 @@ func (d *Dependency) printMissing(chartpath string, out io.Writer, reqs []*chart folder := filepath.Join(chartpath, "charts/*") files, err := filepath.Glob(folder) if err != nil { - fmt.Fprintln(out, err) + _, _ = fmt.Fprintln(out, err) return } for _, f := range files { fi, err := os.Stat(f) if err != nil { - fmt.Fprintf(out, "Warning: %s\n", err) + _, _ = fmt.Fprintf(out, "Warning: %s\n", err) } // Skip anything that is not a directory and not a tgz file. if !fi.IsDir() && filepath.Ext(f) != ".tgz" { @@ -213,7 +213,7 @@ func (d *Dependency) printMissing(chartpath string, out io.Writer, reqs []*chart } c, err := loader.Load(f) if err != nil { - fmt.Fprintf(out, "WARNING: %q is not a chart.\n", f) + _, _ = fmt.Fprintf(out, "WARNING: %q is not a chart.\n", f) continue } found := false @@ -224,7 +224,7 @@ func (d *Dependency) printMissing(chartpath string, out io.Writer, reqs []*chart } } if !found { - fmt.Fprintf(out, "WARNING: %q is not in Chart.yaml.\n", f) + _, _ = fmt.Fprintf(out, "WARNING: %q is not in Chart.yaml.\n", f) } } } diff --git a/pkg/action/install.go b/pkg/action/install.go index 6dce3ccbb..48a3fbab1 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -55,7 +55,7 @@ import ( "helm.sh/helm/v3/pkg/storage/driver" ) -// NOTESFILE_SUFFIX that we want to treat special. It goes through the templating engine +// NOTESFILE_SUFFIX that we want to treat special. It goes through the templating engine, // but it's not a yaml file (resource) hence can't have hooks, etc. And the user actually // wants to see this file after rendering in the status command. However, it must be a suffix // since there can be filepath in front of it. @@ -75,7 +75,7 @@ type Install struct { DryRun bool DryRunOption string // HideSecret can be set to true when DryRun is enabled in order to hide - // Kubernetes Secrets in the output. It cannot be used outside of DryRun. + // Kubernetes Secrets in the output. It cannot be used outside DryRun. HideSecret bool DisableHooks bool Replace bool @@ -110,7 +110,7 @@ type Install struct { // OutputDir/ UseReleaseName bool PostRenderer postrender.PostRenderer - // Lock to control raceconditions when the process receives a SIGTERM + // Lock to control race conditions when the process receives a SIGTERM Lock sync.Mutex } @@ -119,7 +119,7 @@ type ChartPathOptions struct { CaFile string // --ca-file CertFile string // --cert-file KeyFile string // --key-file - InsecureSkipTLSverify bool // --insecure-skip-verify + InsecureSkipTLSVerify bool // --insecure-skip-verify PlainHTTP bool // --plain-http Keyring string // --keyring Password string // --password @@ -222,7 +222,7 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release. return i.RunWithContext(ctx, chrt, vals) } -// Run executes the installation with Context +// RunWithContext executes the installation with Context // // When the task is cancelled through ctx, the function returns and the install // proceeds in the background. @@ -264,7 +264,7 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma } if i.ClientOnly { - // Add mock objects in here so it doesn't use Kube API server + // Add mock objects in here, so it doesn't use Kube API server // NOTE(bacongobbler): used for `helm template` i.cfg.Capabilities = chartutil.DefaultCapabilities.Copy() if i.KubeVersion != nil { @@ -382,7 +382,7 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma } } - // If Replace is true, we need to supercede the last release. + // If Replace is true, we need to supersede the last release. if i.Replace { if err := i.replaceRelease(rel); err != nil { return nil, err @@ -504,7 +504,7 @@ func (i *Install) failRelease(rel *release.Release, err error) (*release.Release } return rel, errors.Wrapf(err, "release %s failed, and has been uninstalled due to atomic being set", i.ReleaseName) } - i.recordRelease(rel) // Ignore the error, since we have another error to deal with. + _ = i.recordRelease(rel) // Ignore the error, since we have another error to deal with. return rel, err } @@ -761,7 +761,7 @@ func (c *ChartPathOptions) LocateChart(name string, settings *cli.EnvSettings) ( Options: []getter.Option{ getter.WithPassCredentialsAll(c.PassCredentialsAll), getter.WithTLSClientConfig(c.CertFile, c.KeyFile, c.CaFile), - getter.WithInsecureSkipVerifyTLS(c.InsecureSkipTLSverify), + getter.WithInsecureSkipVerifyTLS(c.InsecureSkipTLSVerify), getter.WithPlainHTTP(c.PlainHTTP), }, RepositoryConfig: settings.RepositoryConfig, @@ -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 } @@ -816,9 +816,9 @@ func (c *ChartPathOptions) LocateChart(name string, settings *cli.EnvSettings) ( return "", err } - lname, err := filepath.Abs(filename) + abs, err := filepath.Abs(filename) if err != nil { return filename, err } - return lname, nil + return abs, nil } diff --git a/pkg/action/pull.go b/pkg/action/pull.go index 787553125..e71a5bdab 100644 --- a/pkg/action/pull.go +++ b/pkg/action/pull.go @@ -89,7 +89,7 @@ func (p *Pull) Run(chartRef string) (string, error) { getter.WithBasicAuth(p.Username, p.Password), getter.WithPassCredentialsAll(p.PassCredentialsAll), getter.WithTLSClientConfig(p.CertFile, p.KeyFile, p.CaFile), - getter.WithInsecureSkipVerifyTLS(p.InsecureSkipTLSverify), + getter.WithInsecureSkipVerifyTLS(p.InsecureSkipTLSVerify), getter.WithPlainHTTP(p.PlainHTTP), }, RegistryClient: p.cfg.RegistryClient, @@ -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 } @@ -136,10 +136,10 @@ func (p *Pull) Run(chartRef string) (string, error) { if p.Verify { for name := range v.SignedBy.Identities { - fmt.Fprintf(&out, "Signed by: %v\n", name) + _, _ = fmt.Fprintf(&out, "Signed by: %v\n", name) } - fmt.Fprintf(&out, "Using Key With Fingerprint: %X\n", v.SignedBy.PrimaryKey.Fingerprint) - fmt.Fprintf(&out, "Chart Hash Verified: %s\n", v.FileHash) + _, _ = fmt.Fprintf(&out, "Using Key With Fingerprint: %X\n", v.SignedBy.PrimaryKey.Fingerprint) + _, _ = fmt.Fprintf(&out, "Chart Hash Verified: %s\n", v.FileHash) } // After verification, untar the chart into the requested directory. diff --git a/pkg/action/release_testing.go b/pkg/action/release_testing.go index aaffe47ca..069a837c6 100644 --- a/pkg/action/release_testing.go +++ b/pkg/action/release_testing.go @@ -131,9 +131,9 @@ func (r *ReleaseTesting) GetPodLogs(out io.Writer, rel *release.Release) error { return errors.Wrapf(err, "unable to get pod logs for %s", h.Name) } - fmt.Fprintf(out, "POD LOGS: %s\n", h.Name) + _, _ = fmt.Fprintf(out, "POD LOGS: %s\n", h.Name) _, err = io.Copy(out, logReader) - fmt.Fprintln(out) + _, _ = fmt.Fprintln(out) if err != nil { return errors.Wrapf(err, "unable to write pod logs for %s", h.Name) } diff --git a/pkg/action/show.go b/pkg/action/show.go index 6ed855b83..2b0ed54a3 100644 --- a/pkg/action/show.go +++ b/pkg/action/show.go @@ -104,12 +104,12 @@ func (s *Show) Run(chartpath string) (string, error) { var out strings.Builder if s.OutputFormat == ShowChart || s.OutputFormat == ShowAll { - fmt.Fprintf(&out, "%s\n", cf) + _, _ = fmt.Fprintf(&out, "%s\n", cf) } if (s.OutputFormat == ShowValues || s.OutputFormat == ShowAll) && s.chart.Values != nil { if s.OutputFormat == ShowAll { - fmt.Fprintln(&out, "---") + _, _ = fmt.Fprintln(&out, "---") } if s.JSONPathTemplate != "" { printer, err := printers.NewJSONPathPrinter(s.JSONPathTemplate) @@ -119,8 +119,8 @@ func (s *Show) Run(chartpath string) (string, error) { printer.Execute(&out, s.chart.Values) } else { for _, f := range s.chart.Raw { - if f.Name == chartutil.ValuesfileName { - fmt.Fprintln(&out, string(f.Data)) + if f.Name == chartutil.ValuesFileName { + _, _ = fmt.Fprintln(&out, string(f.Data)) } } } @@ -130,9 +130,9 @@ func (s *Show) Run(chartpath string) (string, error) { readme := findReadme(s.chart.Files) if readme != nil { if s.OutputFormat == ShowAll { - fmt.Fprintln(&out, "---") + _, _ = fmt.Fprintln(&out, "---") } - fmt.Fprintf(&out, "%s\n", readme.Data) + _, _ = fmt.Fprintf(&out, "%s\n", readme.Data) } } @@ -140,10 +140,10 @@ func (s *Show) Run(chartpath string) (string, error) { crds := s.chart.CRDObjects() if len(crds) > 0 { if s.OutputFormat == ShowAll && !bytes.HasPrefix(crds[0].File.Data, []byte("---")) { - fmt.Fprintln(&out, "---") + _, _ = fmt.Fprintln(&out, "---") } for _, crd := range crds { - fmt.Fprintf(&out, "%s\n", string(crd.File.Data)) + _, _ = fmt.Fprintf(&out, "%s\n", string(crd.File.Data)) } } } diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index 6d26a754e..eddecf229 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -111,7 +111,7 @@ type Upgrade struct { DisableOpenAPIValidation bool // Get missing dependencies DependencyUpdate bool - // Lock to control raceconditions when the process receives a SIGTERM + // Lock to control race conditions when the process receives a SIGTERM Lock sync.Mutex // Enable DNS lookups when rendering templates EnableDNS bool diff --git a/pkg/action/verify.go b/pkg/action/verify.go index f36239496..d18bf142d 100644 --- a/pkg/action/verify.go +++ b/pkg/action/verify.go @@ -45,10 +45,10 @@ func (v *Verify) Run(chartfile string) error { } for name := range p.SignedBy.Identities { - fmt.Fprintf(&out, "Signed by: %v\n", name) + _, _ = fmt.Fprintf(&out, "Signed by: %v\n", name) } - fmt.Fprintf(&out, "Using Key With Fingerprint: %X\n", p.SignedBy.PrimaryKey.Fingerprint) - fmt.Fprintf(&out, "Chart Hash Verified: %s\n", p.FileHash) + _, _ = fmt.Fprintf(&out, "Using Key With Fingerprint: %X\n", p.SignedBy.PrimaryKey.Fingerprint) + _, _ = fmt.Fprintf(&out, "Chart Hash Verified: %s\n", p.FileHash) // TODO(mattfarina): The output is set as a property rather than returned // to maintain the Go API. In Helm v4 this function should return the out diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go index a3bed63a3..8c163e871 100644 --- a/pkg/chart/chart.go +++ b/pkg/chart/chart.go @@ -38,7 +38,7 @@ type Chart struct { // This should not be used except in special cases like `helm show values`, // where we want to display the raw values, comments and all. Raw []*File `json:"-"` - // Metadata is the contents of the Chartfile. + // Metadata is the contents of the ChartFile. Metadata *Metadata `json:"metadata"` // Lock is the contents of Chart.lock. Lock *Lock `json:"lock"` @@ -156,8 +156,8 @@ func (ch *Chart) CRDObjects() []CRD { // Find all resources in the crds/ directory for _, f := range ch.Files { if strings.HasPrefix(f.Name, "crds/") && hasManifestExtension(f.Name) { - mycrd := CRD{Name: f.Name, Filename: filepath.Join(ch.ChartFullPath(), f.Name), File: f} - crds = append(crds, mycrd) + crd := CRD{Name: f.Name, Filename: filepath.Join(ch.ChartFullPath(), f.Name), File: f} + crds = append(crds, crd) } } // Get CRDs from dependencies, too. @@ -167,7 +167,7 @@ func (ch *Chart) CRDObjects() []CRD { return crds } -func hasManifestExtension(fname string) bool { - ext := filepath.Ext(fname) +func hasManifestExtension(filename string) bool { + ext := filepath.Ext(filename) return strings.EqualFold(ext, ".yaml") || strings.EqualFold(ext, ".yml") || strings.EqualFold(ext, ".json") } diff --git a/pkg/chartutil/capabilities.go b/pkg/chartutil/capabilities.go index 5f57e11a5..e38068041 100644 --- a/pkg/chartutil/capabilities.go +++ b/pkg/chartutil/capabilities.go @@ -53,7 +53,7 @@ var ( type Capabilities struct { // KubeVersion is the Kubernetes version. KubeVersion KubeVersion - // APIversions are supported Kubernetes API versions. + // APIVersions are supported Kubernetes API versions. APIVersions VersionSet // HelmVersion is the build information for this helm version HelmVersion helmversion.BuildInfo @@ -111,11 +111,11 @@ func (v VersionSet) Has(apiVersion string) bool { } func allKnownVersions() VersionSet { - // We should register the built in extension APIs as well so CRDs are + // We should register the built-in extension APIs as well so CRDs are // supported in the default version set. This has caused problems with `helm // template` in the past, so let's be safe - apiextensionsv1beta1.AddToScheme(scheme.Scheme) - apiextensionsv1.AddToScheme(scheme.Scheme) + _ = apiextensionsv1beta1.AddToScheme(scheme.Scheme) + _ = apiextensionsv1.AddToScheme(scheme.Scheme) groups := scheme.Scheme.PrioritizedVersionsAllGroups() vs := make(VersionSet, 0, len(groups)) diff --git a/pkg/chartutil/chartfile.go b/pkg/chartutil/chartfile.go index 4f537a6e7..014c6e600 100644 --- a/pkg/chartutil/chartfile.go +++ b/pkg/chartutil/chartfile.go @@ -26,8 +26,8 @@ import ( "helm.sh/helm/v3/pkg/chart" ) -// LoadChartfile loads a Chart.yaml file into a *chart.Metadata. -func LoadChartfile(filename string) (*chart.Metadata, error) { +// LoadChartFile loads a Chart.yaml file into a *chart.Metadata. +func LoadChartFile(filename string) (*chart.Metadata, error) { b, err := os.ReadFile(filename) if err != nil { return nil, err @@ -37,10 +37,10 @@ func LoadChartfile(filename string) (*chart.Metadata, error) { return y, err } -// SaveChartfile saves the given metadata as a Chart.yaml file at the given path. +// SaveChartFile saves the given metadata as a Chart.yaml file at the given path. // // 'filename' should be the complete path and filename ('foo/Chart.yaml') -func SaveChartfile(filename string, cf *chart.Metadata) error { +func SaveChartFile(filename string, cf *chart.Metadata) error { // Pull out the dependencies of a v1 Chart, since there's no way // to tell the serializer to skip a field for just this use case savedDependencies := cf.Dependencies @@ -67,14 +67,14 @@ func IsChartDir(dirName string) (bool, error) { return false, errors.Errorf("%q is not a directory", dirName) } - chartYaml := filepath.Join(dirName, ChartfileName) + chartYaml := filepath.Join(dirName, ChartFileName) if _, err := os.Stat(chartYaml); os.IsNotExist(err) { - return false, errors.Errorf("no %s exists in directory %q", ChartfileName, dirName) + return false, errors.Errorf("no %s exists in directory %q", ChartFileName, dirName) } chartYamlContent, err := os.ReadFile(chartYaml) if err != nil { - return false, errors.Errorf("cannot read %s in directory %q", ChartfileName, dirName) + return false, errors.Errorf("cannot read %s in directory %q", ChartFileName, dirName) } chartContent := new(chart.Metadata) @@ -82,10 +82,10 @@ func IsChartDir(dirName string) (bool, error) { return false, err } if chartContent == nil { - return false, errors.Errorf("chart metadata (%s) missing", ChartfileName) + return false, errors.Errorf("chart metadata (%s) missing", ChartFileName) } if chartContent.Name == "" { - return false, errors.Errorf("invalid chart (%s): name must not be empty", ChartfileName) + return false, errors.Errorf("invalid chart (%s): name must not be empty", ChartFileName) } return true, nil diff --git a/pkg/chartutil/chartfile_test.go b/pkg/chartutil/chartfile_test.go index ef5c5462a..b1591c16b 100644 --- a/pkg/chartutil/chartfile_test.go +++ b/pkg/chartutil/chartfile_test.go @@ -24,19 +24,19 @@ import ( const testfile = "testdata/chartfiletest.yaml" -func TestLoadChartfile(t *testing.T) { - f, err := LoadChartfile(testfile) +func TestLoadChartFile(t *testing.T) { + f, err := LoadChartFile(testfile) if err != nil { t.Errorf("Failed to open %s: %s", testfile, err) return } - verifyChartfile(t, f, "frobnitz") + verifyChartFile(t, f, "frobnitz") } -func verifyChartfile(t *testing.T, f *chart.Metadata, name string) { +func verifyChartFile(t *testing.T, f *chart.Metadata, name string) { if f == nil { //nolint:staticcheck - t.Fatal("Failed verifyChartfile because f is nil") + t.Fatal("Failed verifyChartFile because f is nil") } if f.APIVersion != chart.APIVersionV1 { //nolint:staticcheck diff --git a/pkg/chartutil/coalesce.go b/pkg/chartutil/coalesce.go index f0272fd6a..ba8c4d59a 100644 --- a/pkg/chartutil/coalesce.go +++ b/pkg/chartutil/coalesce.go @@ -33,14 +33,14 @@ func concatPrefix(a, b string) string { return fmt.Sprintf("%s.%s", a, b) } -// CoalesceValues coalesces all of the values in a chart (and its subcharts). +// CoalesceValues coalesces all the values in a chart (and its subcharts). // // Values are coalesced together using the following rules: // // - Values in a higher level chart always override values in a lower-level // dependency chart // - Scalar values and arrays are replaced, maps are merged -// - A chart has access to all of the variables for it, as well as all of +// - A chart has access to all the variables for it, as well as all // the values destined for its dependencies. func CoalesceValues(chrt *chart.Chart, vals map[string]interface{}) (Values, error) { valsCopy, err := copyValues(vals) @@ -58,7 +58,7 @@ func CoalesceValues(chrt *chart.Chart, vals map[string]interface{}) (Values, err // - Values in a higher level chart always override values in a lower-level // dependency chart // - Scalar values and arrays are replaced, maps are merged -// - A chart has access to all of the variables for it, as well as all of +// - A chart has access to all the variables for it, as well as all // the values destined for its dependencies. // // Retaining Nils is useful when processes early in a Helm action or business @@ -103,21 +103,21 @@ func coalesce(printf printFn, ch *chart.Chart, dest map[string]interface{}, pref // coalesceDeps coalesces the dependencies of the given chart. func coalesceDeps(printf printFn, chrt *chart.Chart, dest map[string]interface{}, prefix string, merge bool) (map[string]interface{}, error) { - for _, subchart := range chrt.Dependencies() { - if c, ok := dest[subchart.Name()]; !ok { + for _, subChart := range chrt.Dependencies() { + if c, ok := dest[subChart.Name()]; !ok { // If dest doesn't already have the key, create it. - dest[subchart.Name()] = make(map[string]interface{}) - } else if !istable(c) { - return dest, errors.Errorf("type mismatch on %s: %t", subchart.Name(), c) + dest[subChart.Name()] = make(map[string]interface{}) + } else if !isTable(c) { + return dest, errors.Errorf("type mismatch on %s: %t", subChart.Name(), c) } - if dv, ok := dest[subchart.Name()]; ok { + if dv, ok := dest[subChart.Name()]; ok { dvmap := dv.(map[string]interface{}) subPrefix := concatPrefix(prefix, chrt.Metadata.Name) // Get globals out of dest and merge them into dvmap. coalesceGlobals(printf, dvmap, dest, subPrefix, merge) // Now coalesce the rest of the values. var err error - dest[subchart.Name()], err = coalesce(printf, subchart, dvmap, subPrefix, merge) + dest[subChart.Name()], err = coalesce(printf, subChart, dvmap, subPrefix, merge) if err != nil { return dest, err } @@ -132,16 +132,16 @@ func coalesceDeps(printf printFn, chrt *chart.Chart, dest map[string]interface{} func coalesceGlobals(printf printFn, dest, src map[string]interface{}, prefix string, _ bool) { var dg, sg map[string]interface{} - if destglob, ok := dest[GlobalKey]; !ok { + if destGlob, ok := dest[GlobalKey]; !ok { dg = make(map[string]interface{}) - } else if dg, ok = destglob.(map[string]interface{}); !ok { + } else if dg, ok = destGlob.(map[string]interface{}); !ok { printf("warning: skipping globals because destination %s is not a table.", GlobalKey) return } - if srcglob, ok := src[GlobalKey]; !ok { + if srcGlob, ok := src[GlobalKey]; !ok { sg = make(map[string]interface{}) - } else if sg, ok = srcglob.(map[string]interface{}); !ok { + } else if sg, ok = srcGlob.(map[string]interface{}); !ok { printf("warning: skipping globals because source %s is not a table.", GlobalKey) return } @@ -151,7 +151,7 @@ func coalesceGlobals(printf printFn, dest, src map[string]interface{}, prefix st // here, but I haven't found a way. So for the time being, let's allow // tables in globals. for key, val := range sg { - if istable(val) { + if isTable(val) { vv := copyMap(val.(map[string]interface{})) if destv, ok := dg[key]; !ok { // Here there is no merge. We're just adding. @@ -170,7 +170,7 @@ func coalesceGlobals(printf printFn, dest, src map[string]interface{}, prefix st dg[key] = vv } } - } else if dv, ok := dg[key]; ok && istable(dv) { + } else if dv, ok := dg[key]; ok && isTable(dv) { // It's not clear if this condition can actually ever trigger. printf("key %s is table. Skipping", key) } else { @@ -279,13 +279,13 @@ func coalesceTablesFullKey(printf printFn, dst, src map[string]interface{}, pref delete(dst, key) } else if !ok { dst[key] = val - } else if istable(val) { - if istable(dv) { + } else if isTable(val) { + if isTable(dv) { coalesceTablesFullKey(printf, dv.(map[string]interface{}), val.(map[string]interface{}), fullkey, merge) } else { printf("warning: cannot overwrite table with non table for %s (%v)", fullkey, val) } - } else if istable(dv) && val != nil { + } else if isTable(dv) && val != nil { printf("warning: destination for %s is a table. Ignoring non-table value (%v)", fullkey, val) } } diff --git a/pkg/chartutil/create.go b/pkg/chartutil/create.go index 50212f9d5..bf5f4df88 100644 --- a/pkg/chartutil/create.go +++ b/pkg/chartutil/create.go @@ -38,20 +38,20 @@ import ( var chartName = regexp.MustCompile("^[a-zA-Z0-9._-]+$") const ( - // ChartfileName is the default Chart file name. - ChartfileName = "Chart.yaml" - // ValuesfileName is the default values file name. - ValuesfileName = "values.yaml" - // SchemafileName is the default values schema file name. - SchemafileName = "values.schema.json" + // ChartFileName is the default Chart file name. + ChartFileName = "Chart.yaml" + // ValuesFileName is the default values file name. + ValuesFileName = "values.yaml" + // SchemaFileName is the default values schema file name. + SchemaFileName = "values.schema.json" // TemplatesDir is the relative directory name for templates. TemplatesDir = "templates" // ChartsDir is the relative directory name for charts dependencies. ChartsDir = "charts" // TemplatesTestsDir is the relative directory name for tests. TemplatesTestsDir = TemplatesDir + sep + "tests" - // IgnorefileName is the name of the Helm ignore file. - IgnorefileName = ".helmignore" + // IgnoreFileName is the name of the Helm ignore file. + IgnoreFileName = ".helmignore" // IngressFileName is the name of the example ingress file. IngressFileName = TemplatesDir + sep + "ingress.yaml" // DeploymentName is the name of the example deployment file. @@ -76,7 +76,7 @@ const maxChartNameLength = 250 const sep = string(filepath.Separator) -const defaultChartfile = `apiVersion: v2 +const defaultChartFile = `apiVersion: v2 name: %s description: A Helm chart for Kubernetes @@ -578,7 +578,7 @@ func CreateFrom(chartfile *chart.Metadata, dest, src string) error { // key in order to preserve the comments in the YAML. The name placeholder // needs to be replaced on that file. for _, f := range schart.Raw { - if f.Name == ValuesfileName { + if f.Name == ValuesFileName { f.Data = transform(string(f.Data), schart.Name()) } } @@ -628,17 +628,17 @@ func Create(name, dir string) (string, error) { }{ { // Chart.yaml - path: filepath.Join(cdir, ChartfileName), - content: []byte(fmt.Sprintf(defaultChartfile, name)), + path: filepath.Join(cdir, ChartFileName), + content: []byte(fmt.Sprintf(defaultChartFile, name)), }, { // values.yaml - path: filepath.Join(cdir, ValuesfileName), + path: filepath.Join(cdir, ValuesFileName), content: []byte(fmt.Sprintf(defaultValues, name)), }, { // .helmignore - path: filepath.Join(cdir, IgnorefileName), + path: filepath.Join(cdir, IgnoreFileName), content: []byte(defaultIgnore), }, { @@ -686,7 +686,7 @@ func Create(name, dir string) (string, error) { for _, file := range files { if _, err := os.Stat(file.path); err == nil { // There is no handle to a preferred output stream here. - fmt.Fprintf(Stderr, "WARNING: File %q already exists. Overwriting.\n", file.path) + _, _ = fmt.Fprintf(Stderr, "WARNING: File %q already exists. Overwriting.\n", file.path) } if err := writeFile(file.path, file.content); err != nil { return cdir, err diff --git a/pkg/chartutil/create_test.go b/pkg/chartutil/create_test.go index 1697c4218..96c8e2e53 100644 --- a/pkg/chartutil/create_test.go +++ b/pkg/chartutil/create_test.go @@ -46,17 +46,17 @@ func TestCreate(t *testing.T) { } for _, f := range []string{ - ChartfileName, + ChartFileName, DeploymentName, HelpersName, - IgnorefileName, + IgnoreFileName, NotesName, ServiceAccountName, ServiceName, TemplatesDir, TemplatesTestsDir, TestConnectionName, - ValuesfileName, + ValuesFileName, } { if _, err := os.Stat(filepath.Join(dir, f)); err != nil { t.Errorf("Expected %s file: %s", f, err) @@ -90,8 +90,8 @@ func TestCreateFrom(t *testing.T) { } for _, f := range []string{ - ChartfileName, - ValuesfileName, + ChartFileName, + ValuesFileName, filepath.Join(TemplatesDir, "placeholder.tpl"), } { if _, err := os.Stat(filepath.Join(dir, f)); err != nil { diff --git a/pkg/chartutil/dependencies.go b/pkg/chartutil/dependencies.go index 205d99e09..25f9d730b 100644 --- a/pkg/chartutil/dependencies.go +++ b/pkg/chartutil/dependencies.go @@ -335,7 +335,7 @@ func trimNilValues(vals map[string]interface{}) map[string]interface{} { if val == nil { // Iterate over the values and remove nil keys delete(valsCopyMap, key) - } else if istable(val) { + } else if isTable(val) { // Recursively call into ourselves to remove keys from inner tables valsCopyMap[key] = trimNilValues(val.(map[string]interface{})) } diff --git a/pkg/chartutil/jsonschema.go b/pkg/chartutil/jsonschema.go index 7b9768fd3..95d6d99fc 100644 --- a/pkg/chartutil/jsonschema.go +++ b/pkg/chartutil/jsonschema.go @@ -40,9 +40,9 @@ func ValidateAgainstSchema(chrt *chart.Chart, values map[string]interface{}) err } // For each dependency, recursively call this function with the coalesced values - for _, subchart := range chrt.Dependencies() { - subchartValues := values[subchart.Name()].(map[string]interface{}) - if err := ValidateAgainstSchema(subchart, subchartValues); err != nil { + for _, subChart := range chrt.Dependencies() { + subChartValues := values[subChart.Name()].(map[string]interface{}) + if err := ValidateAgainstSchema(subChart, subChartValues); err != nil { sb.WriteString(err.Error()) } } diff --git a/pkg/chartutil/save.go b/pkg/chartutil/save.go index 4ee90709c..4ab7260da 100644 --- a/pkg/chartutil/save.go +++ b/pkg/chartutil/save.go @@ -52,14 +52,14 @@ func SaveDir(c *chart.Chart, dest string) error { } // Save the chart file. - if err := SaveChartfile(filepath.Join(outdir, ChartfileName), c.Metadata); err != nil { + if err := SaveChartFile(filepath.Join(outdir, ChartFileName), c.Metadata); err != nil { return err } // Save values.yaml for _, f := range c.Raw { - if f.Name == ValuesfileName { - vf := filepath.Join(outdir, ValuesfileName) + if f.Name == ValuesFileName { + vf := filepath.Join(outdir, ValuesFileName) if err := writeFile(vf, f.Data); err != nil { return err } @@ -68,7 +68,7 @@ func SaveDir(c *chart.Chart, dest string) error { // Save values.schema.json if it exists if c.Schema != nil { - filename := filepath.Join(outdir, SchemafileName) + filename := filepath.Join(outdir, SchemaFileName) if err := writeFile(filename, c.Schema); err != nil { return err } @@ -173,7 +173,7 @@ func writeTarContents(out *tar.Writer, c *chart.Chart, prefix string) error { if err != nil { return err } - if err := writeToTar(out, filepath.Join(base, ChartfileName), cdata); err != nil { + if err := writeToTar(out, filepath.Join(base, ChartFileName), cdata); err != nil { return err } @@ -193,8 +193,8 @@ func writeTarContents(out *tar.Writer, c *chart.Chart, prefix string) error { // Save values.yaml for _, f := range c.Raw { - if f.Name == ValuesfileName { - if err := writeToTar(out, filepath.Join(base, ValuesfileName), f.Data); err != nil { + if f.Name == ValuesFileName { + if err := writeToTar(out, filepath.Join(base, ValuesFileName), f.Data); err != nil { return err } } @@ -203,9 +203,9 @@ func writeTarContents(out *tar.Writer, c *chart.Chart, prefix string) error { // Save values.schema.json if it exists if c.Schema != nil { if !json.Valid(c.Schema) { - return errors.New("Invalid JSON in " + SchemafileName) + return errors.New("Invalid JSON in " + SchemaFileName) } - if err := writeToTar(out, filepath.Join(base, SchemafileName), c.Schema); err != nil { + if err := writeToTar(out, filepath.Join(base, SchemaFileName), c.Schema); err != nil { return err } } diff --git a/pkg/chartutil/values.go b/pkg/chartutil/values.go index 2fa2bdabb..f853effa5 100644 --- a/pkg/chartutil/values.go +++ b/pkg/chartutil/values.go @@ -165,14 +165,14 @@ func ToRenderValues(chrt *chart.Chart, chrtVals map[string]interface{}, options return top, nil } -// istable is a special-purpose function to see if the present thing matches the definition of a YAML table. -func istable(v interface{}) bool { +// isTable is a special-purpose function to see if the present thing matches the definition of a YAML table. +func isTable(v interface{}) bool { _, ok := v.(map[string]interface{}) return ok } // PathValue takes a path that traverses a YAML structure and returns the value at the end of that path. -// The path starts at the root of the YAML structure and is comprised of YAML keys separated by periods. +// The path starts at the root of the YAML structure and comprises YAML keys separated by periods. // Given the following YAML data the value at path "chapter.one.title" is "Loomings". // // chapter: @@ -188,7 +188,7 @@ func (v Values) PathValue(path string) (interface{}, error) { func (v Values) pathValue(path []string) (interface{}, error) { if len(path) == 1 { // if exists must be root key not table - if _, ok := v[path[0]]; ok && !istable(v[path[0]]) { + if _, ok := v[path[0]]; ok && !isTable(v[path[0]]) { return v[path[0]], nil } return nil, ErrNoValue{path[0]} @@ -201,7 +201,7 @@ func (v Values) pathValue(path []string) (interface{}, error) { return nil, ErrNoValue{key} } // check table for key and ensure value is not a table - if k, ok := t[key]; ok && !istable(k) { + if k, ok := t[key]; ok && !isTable(k) { return k, nil } return nil, ErrNoValue{key} diff --git a/pkg/cli/environment.go b/pkg/cli/environment.go index 438ba1515..ee7cf0143 100644 --- a/pkg/cli/environment.go +++ b/pkg/cli/environment.go @@ -17,7 +17,7 @@ limitations under the License. /* Package cli describes the operating environment for the Helm CLI. -Helm's environment encapsulates all of the service dependencies Helm has. +Helm's environment encapsulates all the service dependencies Helm has. These dependencies are expressed as interfaces so that alternate implementations (mocks, etc.) can be easily generated. */ @@ -47,7 +47,7 @@ const defaultBurstLimit = 100 // defaultQPS sets the default QPS value to 0 to use library defaults unless specified const defaultQPS = float32(0) -// EnvSettings describes all of the environment settings. +// EnvSettings describes all the environment settings. type EnvSettings struct { namespace string config *genericclioptions.ConfigFlags @@ -72,7 +72,7 @@ type EnvSettings struct { // KubeTLSServerName overrides the name to use for server certificate validation. // If it is not provided, the hostname used to contact the server is used KubeTLSServerName string - // Debug indicates whether or not Helm is running in Debug mode. + // Debug indicates whether Helm is running in Debug mode. Debug bool // RegistryConfig is the path to the registry config file. RegistryConfig string @@ -80,7 +80,7 @@ type EnvSettings struct { RepositoryConfig string // RepositoryCache is the path to the repository cache directory. RepositoryCache string - // PluginsDirectory is the path to the plugins directory. + // PluginsDirectory is the path to the plugins' directory. PluginsDirectory string // MaxHistory is the max release history maintained. MaxHistory int diff --git a/pkg/downloader/chart_downloader.go b/pkg/downloader/chart_downloader.go index a95894e00..980f3ee2a 100644 --- a/pkg/downloader/chart_downloader.go +++ b/pkg/downloader/chart_downloader.go @@ -108,9 +108,9 @@ func (c *ChartDownloader) DownloadTo(ref, version, dest string) (string, *proven name = fmt.Sprintf("%s-%s.tgz", name[:idx], name[idx+1:]) } - destfile := filepath.Join(dest, name) - if err := fileutil.AtomicWriteFile(destfile, data, 0644); err != nil { - return destfile, nil, err + destFile := filepath.Join(dest, name) + if err := fileutil.AtomicWriteFile(destFile, data, 0644); err != nil { + return destFile, nil, err } // If provenance is requested, verify it. @@ -119,26 +119,26 @@ func (c *ChartDownloader) DownloadTo(ref, version, dest string) (string, *proven body, err := g.Get(u.String() + ".prov") if err != nil { if c.Verify == VerifyAlways { - return destfile, ver, errors.Errorf("failed to fetch provenance %q", u.String()+".prov") + return destFile, ver, errors.Errorf("failed to fetch provenance %q", u.String()+".prov") } - fmt.Fprintf(c.Out, "WARNING: Verification not found for %s: %s\n", ref, err) - return destfile, ver, nil + _, _ = fmt.Fprintf(c.Out, "WARNING: Verification not found for %s: %s\n", ref, err) + return destFile, ver, nil } - provfile := destfile + ".prov" - if err := fileutil.AtomicWriteFile(provfile, body, 0644); err != nil { - return destfile, nil, err + provFile := destFile + ".prov" + if err := fileutil.AtomicWriteFile(provFile, body, 0644); err != nil { + return destFile, nil, err } if c.Verify != VerifyLater { - ver, err = VerifyChart(destfile, c.Keyring) + ver, err = VerifyChart(destFile, c.Keyring) if err != nil { // Fail always in this case, since it means the verification step // failed. - return destfile, ver, err + return destFile, ver, err } } } - return destfile, ver, nil + return destFile, ver, nil } func (c *ChartDownloader) getOciURI(ref, version string, u *url.URL) (*url.URL, error) { diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index d5340575d..9160851d3 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -267,13 +267,13 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error { } defer os.RemoveAll(tmpPath) - fmt.Fprintf(m.Out, "Saving %d charts\n", len(deps)) + _, _ = fmt.Fprintf(m.Out, "Saving %d charts\n", len(deps)) var saveError error churls := make(map[string]struct{}) for _, dep := range deps { // No repository means the chart is in charts directory if dep.Repository == "" { - fmt.Fprintf(m.Out, "Dependency %s did not declare a repository. Assuming it exists in the charts directory\n", dep.Name) + _, _ = fmt.Fprintf(m.Out, "Dependency %s did not declare a repository. Assuming it exists in the charts directory\n", dep.Name) // NOTE: we are only validating the local dependency conforms to the constraints. No copying to tmpPath is necessary. chartPath := filepath.Join(destPath, dep.Name) ch, err := loader.LoadDir(chartPath) @@ -299,7 +299,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error { } if strings.HasPrefix(dep.Repository, "file://") { if m.Debug { - fmt.Fprintf(m.Out, "Archiving %s from repo %s\n", dep.Name, dep.Repository) + _, _ = fmt.Fprintf(m.Out, "Archiving %s from repo %s\n", dep.Name, dep.Repository) } ver, err := tarFromLocalDir(m.ChartPath, dep.Name, dep.Repository, dep.Version, tmpPath) if err != nil { @@ -319,11 +319,11 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error { } if _, ok := churls[churl]; ok { - fmt.Fprintf(m.Out, "Already downloaded %s from repo %s\n", dep.Name, dep.Repository) + _, _ = fmt.Fprintf(m.Out, "Already downloaded %s from repo %s\n", dep.Name, dep.Repository) continue } - fmt.Fprintf(m.Out, "Downloading %s from repo %s\n", dep.Name, dep.Repository) + _, _ = fmt.Fprintf(m.Out, "Downloading %s from repo %s\n", dep.Name, dep.Repository) dl := ChartDownloader{ Out: m.Out, @@ -367,7 +367,7 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error { return err } } else { - fmt.Fprintln(m.Out, "Save error occurred: ", saveError) + _, _ = fmt.Fprintln(m.Out, "Save error occurred: ", saveError) return saveError } return nil @@ -424,24 +424,24 @@ func (m *Manager) safeMoveDeps(deps []*chart.Dependency, source, dest string) er destfile := filepath.Join(dest, filename) existsInSourceDirectory[filename] = true if _, err := loader.LoadFile(sourcefile); err != nil { - fmt.Fprintf(m.Out, "Could not verify %s for moving: %s (Skipping)", sourcefile, err) + _, _ = fmt.Fprintf(m.Out, "Could not verify %s for moving: %s (Skipping)", sourcefile, err) continue } // NOTE: no need to delete the dest; os.Rename replaces it. if err := fs.RenameWithFallback(sourcefile, destfile); err != nil { - fmt.Fprintf(m.Out, "Unable to move %s to charts dir %s (Skipping)", sourcefile, err) + _, _ = fmt.Fprintf(m.Out, "Unable to move %s to charts dir %s (Skipping)", sourcefile, err) continue } } - fmt.Fprintln(m.Out, "Deleting outdated charts") + _, _ = fmt.Fprintln(m.Out, "Deleting outdated charts") // find all files that exist in dest that do not exist in source; delete them (outdated dependencies) for _, file := range destFiles { if !file.IsDir() && !existsInSourceDirectory[file.Name()] { fname := filepath.Join(dest, file.Name()) ch, err := loader.LoadFile(fname) if err != nil { - fmt.Fprintf(m.Out, "Could not verify %s for deletion: %s (Skipping)\n", fname, err) + _, _ = fmt.Fprintf(m.Out, "Could not verify %s for deletion: %s (Skipping)\n", fname, err) continue } // local dependency - skip @@ -449,7 +449,7 @@ func (m *Manager) safeMoveDeps(deps []*chart.Dependency, source, dest string) er continue } if err := os.Remove(fname); err != nil { - fmt.Fprintf(m.Out, "Could not delete %s: %s (Skipping)", fname, err) + _, _ = fmt.Fprintf(m.Out, "Could not delete %s: %s (Skipping)", fname, err) continue } } @@ -545,7 +545,7 @@ func (m *Manager) ensureMissingRepos(repoNames map[string]string, deps []*chart. // the dependencies that are not known to the user if update skipping // is not configured. if !m.SkipUpdate && len(ru) > 0 { - fmt.Fprintln(m.Out, "Getting updates for unmanaged Helm repositories...") + _, _ = fmt.Fprintln(m.Out, "Getting updates for unmanaged Helm repositories...") if err := m.parallelRepoUpdate(ru); err != nil { return repoNames, err } @@ -583,7 +583,7 @@ func (m *Manager) resolveRepoNames(deps []*chart.Dependency) (map[string]string, } if m.Debug { - fmt.Fprintf(m.Out, "Repository from local path: %s\n", dd.Repository) + _, _ = fmt.Fprintf(m.Out, "Repository from local path: %s\n", dd.Repository) } reposMap[dd.Name] = dd.Repository continue @@ -649,12 +649,12 @@ func (m *Manager) UpdateRepositories() error { } repos := rf.Repositories if len(repos) > 0 { - fmt.Fprintln(m.Out, "Hang tight while we grab the latest from your chart repositories...") + _, _ = fmt.Fprintln(m.Out, "Hang tight while we grab the latest from your chart repositories...") // This prints warnings straight to out. if err := m.parallelRepoUpdate(repos); err != nil { return err } - fmt.Fprintln(m.Out, "Update Complete. ⎈Happy Helming!⎈") + _, _ = fmt.Fprintln(m.Out, "Update Complete. ⎈Happy Helming!⎈") } return nil } @@ -674,17 +674,17 @@ func (m *Manager) parallelRepoUpdate(repos []*repo.Entry) error { // For those dependencies that are not known to helm and using a // generated key name we display the repo url. if strings.HasPrefix(r.Config.Name, managerKeyPrefix) { - fmt.Fprintf(m.Out, "...Unable to get an update from the %q chart repository:\n\t%s\n", r.Config.URL, err) + _, _ = fmt.Fprintf(m.Out, "...Unable to get an update from the %q chart repository:\n\t%s\n", r.Config.URL, err) } else { - fmt.Fprintf(m.Out, "...Unable to get an update from the %q chart repository (%s):\n\t%s\n", r.Config.Name, r.Config.URL, err) + _, _ = fmt.Fprintf(m.Out, "...Unable to get an update from the %q chart repository (%s):\n\t%s\n", r.Config.Name, r.Config.URL, err) } } else { // For those dependencies that are not known to helm and using a // generated key name we display the repo url. if strings.HasPrefix(r.Config.Name, managerKeyPrefix) { - fmt.Fprintf(m.Out, "...Successfully got an update from the %q chart repository\n", r.Config.URL) + _, _ = fmt.Fprintf(m.Out, "...Successfully got an update from the %q chart repository\n", r.Config.URL) } else { - fmt.Fprintf(m.Out, "...Successfully got an update from the %q chart repository\n", r.Config.Name) + _, _ = fmt.Fprintf(m.Out, "...Successfully got an update from the %q chart repository\n", r.Config.Name) } } wg.Done() diff --git a/pkg/getter/getter.go b/pkg/getter/getter.go index 45ab4da7e..f2aa1793e 100644 --- a/pkg/getter/getter.go +++ b/pkg/getter/getter.go @@ -201,7 +201,7 @@ var ociProvider = Provider{ New: NewOCIGetter, } -// All finds all of the registered getters as a list of Provider instances. +// All finds all the registered getters as a list of Provider instances. // Currently, the built-in getters and the discovered plugins with downloader // notations are collected. func All(settings *cli.EnvSettings) Providers { diff --git a/pkg/getter/httpgetter_test.go b/pkg/getter/httpgetter_test.go index 0ba7e03e8..b02ca7fca 100644 --- a/pkg/getter/httpgetter_test.go +++ b/pkg/getter/httpgetter_test.go @@ -160,7 +160,7 @@ func TestDownload(t *testing.T) { if r.UserAgent() != defaultUserAgent { t.Errorf("Expected '%s', got '%s'", defaultUserAgent, r.UserAgent()) } - fmt.Fprint(w, expect) + _, _ = fmt.Fprint(w, expect) })) defer srv.Close() @@ -187,7 +187,7 @@ func TestDownload(t *testing.T) { if r.UserAgent() != expectedUserAgent { t.Errorf("Expected '%s', got '%s'", expectedUserAgent, r.UserAgent()) } - fmt.Fprint(w, expect) + _, _ = fmt.Fprint(w, expect) })) defer basicAuthSrv.Close() @@ -217,7 +217,7 @@ func TestDownload(t *testing.T) { if ok || username == "username" || password == "password" { t.Errorf("Expected request to not include but got '%v', '%s', '%s'", ok, username, password) } - fmt.Fprint(w, expect) + _, _ = fmt.Fprint(w, expect) })) defer crossAuthSrv.Close() @@ -252,7 +252,7 @@ func TestDownload(t *testing.T) { if !ok || username != "username" || password != "password" { t.Errorf("Expected request to use basic auth and for username == 'username' and password == 'password', got '%v', '%s', '%s'", ok, username, password) } - fmt.Fprint(w, expect) + _, _ = fmt.Fprint(w, expect) })) defer crossAuthSrv.Close() diff --git a/pkg/getter/plugingetter.go b/pkg/getter/plugingetter.go index a371b52eb..a8758e2dd 100644 --- a/pkg/getter/plugingetter.go +++ b/pkg/getter/plugingetter.go @@ -37,15 +37,15 @@ func collectPlugins(settings *cli.EnvSettings) (Providers, error) { return nil, err } var result Providers - for _, plugin := range plugins { - for _, downloader := range plugin.Metadata.Downloaders { + for _, plg := range plugins { + for _, downloader := range plg.Metadata.Downloaders { result = append(result, Provider{ Schemes: downloader.Protocols, New: NewPluginGetter( downloader.Command, settings, - plugin.Metadata.Name, - plugin.Dir, + plg.Metadata.Name, + plg.Dir, ), }) } diff --git a/pkg/helmpath/lazypath.go b/pkg/helmpath/lazypath.go index 22d7bf0a1..69d4c4f95 100644 --- a/pkg/helmpath/lazypath.go +++ b/pkg/helmpath/lazypath.go @@ -34,12 +34,12 @@ const ( DataHomeEnvVar = "HELM_DATA_HOME" ) -// lazypath is an lazy-loaded path buffer for the XDG base directory specification. +// lazypath is a lazy-loaded path buffer for the XDG base directory specification. type lazypath string func (l lazypath) path(helmEnvVar, xdgEnvVar string, defaultFn func() string, elem ...string) string { - // There is an order to checking for a path. + // There is an order to check for a path. // 1. See if a Helm specific environment variable has been set. // 2. Check if an XDG environment variable is set // 3. Fall back to a default diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 9df833a43..497ef1734 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -175,7 +175,7 @@ func (c *Client) Get(resources ResourceList, related bool) (map[string][]runtime vk := gvk.Version + "/" + gvk.Kind obj, err := getResource(info) if err != nil { - fmt.Fprintf(buf, "Get resource %s failed, err:%v\n", info.Name, err) + _, _ = fmt.Fprintf(buf, "Get resource %s failed, err:%v\n", info.Name, err) } else { objs[vk] = append(objs[vk], obj) diff --git a/pkg/kube/factory.go b/pkg/kube/factory.go index f19d62dc3..87457d26e 100644 --- a/pkg/kube/factory.go +++ b/pkg/kube/factory.go @@ -46,6 +46,6 @@ type Factory interface { // and which implements the common patterns for CLI interactions with generic resources. NewBuilder() *resource.Builder - // Returns a schema that can validate objects stored on disk. + // Validator Returns a schema that can validate objects stored on disk. Validator(validationDirective string) (validation.Schema, error) } diff --git a/pkg/lint/lint.go b/pkg/lint/lint.go index c0e79f55b..02aab9905 100644 --- a/pkg/lint/lint.go +++ b/pkg/lint/lint.go @@ -35,7 +35,7 @@ func AllWithKubeVersion(basedir string, values map[string]interface{}, namespace chartDir, _ := filepath.Abs(basedir) linter := support.Linter{ChartDir: chartDir} - rules.Chartfile(&linter) + rules.ChartFile(&linter) rules.ValuesWithOverrides(&linter, values) rules.TemplatesWithKubeVersion(&linter, values, namespace, kubeVersion) rules.Dependencies(&linter) diff --git a/pkg/lint/rules/chartfile.go b/pkg/lint/rules/chartfile.go index 910602b7d..e48b52924 100644 --- a/pkg/lint/rules/chartfile.go +++ b/pkg/lint/rules/chartfile.go @@ -31,14 +31,14 @@ import ( "helm.sh/helm/v3/pkg/lint/support" ) -// Chartfile runs a set of linter rules related to Chart.yaml file -func Chartfile(linter *support.Linter) { +// ChartFile runs a set of linter rules related to Chart.yaml file +func ChartFile(linter *support.Linter) { chartFileName := "Chart.yaml" chartPath := filepath.Join(linter.ChartDir, chartFileName) linter.RunLinterRule(support.ErrorSev, chartFileName, validateChartYamlNotDirectory(chartPath)) - chartFile, err := chartutil.LoadChartfile(chartPath) + chartFile, err := chartutil.LoadChartFile(chartPath) validChartFile := linter.RunLinterRule(support.ErrorSev, chartFileName, validateChartYamlFormat(err)) // Guard clause. Following linter rules require a parsable ChartFile diff --git a/pkg/lint/rules/chartfile_test.go b/pkg/lint/rules/chartfile_test.go index a06d7dc31..7712e9583 100644 --- a/pkg/lint/rules/chartfile_test.go +++ b/pkg/lint/rules/chartfile_test.go @@ -41,8 +41,8 @@ var ( nonExistingChartFilePath = filepath.Join(os.TempDir(), "Chart.yaml") ) -var badChart, _ = chartutil.LoadChartfile(badChartFilePath) -var badChartName, _ = chartutil.LoadChartfile(badChartNamePath) +var badChart, _ = chartutil.LoadChartFile(badChartFilePath) +var badChartName, _ = chartutil.LoadChartFile(badChartNamePath) // Validation functions Test func TestValidateChartYamlNotDirectory(t *testing.T) { @@ -192,10 +192,10 @@ func TestValidateChartIconURL(t *testing.T) { } } -func TestChartfile(t *testing.T) { +func TestChartFile(t *testing.T) { t.Run("Chart.yaml basic validity issues", func(t *testing.T) { linter := support.Linter{ChartDir: badChartDir} - Chartfile(&linter) + ChartFile(&linter) msgs := linter.Messages expectedNumberOfErrorMessages := 6 @@ -231,7 +231,7 @@ func TestChartfile(t *testing.T) { t.Run("Chart.yaml validity issues due to type mismatch", func(t *testing.T) { linter := support.Linter{ChartDir: anotherBadChartDir} - Chartfile(&linter) + ChartFile(&linter) msgs := linter.Messages expectedNumberOfErrorMessages := 3 diff --git a/pkg/plugin/installer/http_installer_test.go b/pkg/plugin/installer/http_installer_test.go index f0fe36ecd..c718ece46 100644 --- a/pkg/plugin/installer/http_installer_test.go +++ b/pkg/plugin/installer/http_installer_test.go @@ -70,11 +70,11 @@ func mockArchiveServer() *httptest.Server { return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if !strings.HasSuffix(r.URL.Path, ".tar.gz") { w.Header().Add("Content-Type", "text/html") - fmt.Fprintln(w, "broken") + _, _ = fmt.Fprintln(w, "broken") return } w.Header().Add("Content-Type", "application/gzip") - fmt.Fprintln(w, "test") + _, _ = fmt.Fprintln(w, "test") })) } diff --git a/pkg/provenance/sign_test.go b/pkg/provenance/sign_test.go index bf6848368..2b996dfdf 100644 --- a/pkg/provenance/sign_test.go +++ b/pkg/provenance/sign_test.go @@ -17,6 +17,7 @@ package provenance import ( "crypto" + "errors" "fmt" "io" "os" @@ -37,16 +38,16 @@ const ( // testPasswordKeyFile is a keyfile with a password. testPasswordKeyfile = "testdata/helm-password-key.secret" - // testPubfile is the public key file. + // testPubFile is the public key file. // Use `gpg --export helm-test` to export the public key. - testPubfile = "testdata/helm-test-key.pub" + testPubFile = "testdata/helm-test-key.pub" // Generated name for the PGP key in testKeyFile. testKeyName = `Helm Testing (This key should only be used for testing. DO NOT TRUST.) ` testPasswordKeyName = `password key (fake) ` - testChartfile = "testdata/hashtest-1.2.3.tgz" + testChartFile = "testdata/hashtest-1.2.3.tgz" // testSigBlock points to a signature generated by an external tool. // This file was generated with GnuPG: @@ -56,12 +57,12 @@ const ( // testTamperedSigBlock is a tampered copy of msgblock.yaml.asc testTamperedSigBlock = "testdata/msgblock.yaml.tampered" - // testSumfile points to a SHA256 sum generated by an external tool. + // testSumFile points to a SHA256 sum generated by an external tool. // We always want to validate against an external tool's representation to // verify that we haven't done something stupid. This file was generated // with shasum. // shasum -a 256 hashtest-1.2.3.tgz > testdata/hashtest.sha256 - testSumfile = "testdata/hashtest.sha256" + testSumFile = "testdata/hashtest.sha256" ) // testMessageBlock represents the expected message block for the testdata/hashtest chart. @@ -76,7 +77,7 @@ files: ` func TestMessageBlock(t *testing.T) { - out, err := messageBlock(testChartfile) + out, err := messageBlock(testChartFile) if err != nil { t.Fatal(err) } @@ -120,7 +121,7 @@ func TestLoadKey(t *testing.T) { } func TestLoadKeyRing(t *testing.T) { - k, err := loadKeyRing(testPubfile) + k, err := loadKeyRing(testPubFile) if err != nil { t.Fatal(err) } @@ -137,7 +138,7 @@ func TestLoadKeyRing(t *testing.T) { } func TestDigest(t *testing.T) { - f, err := os.Open(testChartfile) + f, err := os.Open(testChartFile) if err != nil { t.Fatal(err) } @@ -148,7 +149,7 @@ func TestDigest(t *testing.T) { t.Fatal(err) } - sig, err := readSumFile(testSumfile) + sig, err := readSumFile(testSumFile) if err != nil { t.Fatal(err) } @@ -159,7 +160,7 @@ func TestDigest(t *testing.T) { } func TestNewFromFiles(t *testing.T) { - s, err := NewFromFiles(testKeyfile, testPubfile) + s, err := NewFromFiles(testKeyfile, testPubFile) if err != nil { t.Fatal(err) } @@ -170,12 +171,12 @@ func TestNewFromFiles(t *testing.T) { } func TestDigestFile(t *testing.T) { - hash, err := DigestFile(testChartfile) + hash, err := DigestFile(testChartFile) if err != nil { t.Fatal(err) } - sig, err := readSumFile(testSumfile) + sig, err := readSumFile(testSumFile) if err != nil { t.Fatal(err) } @@ -216,12 +217,12 @@ func TestDecryptKey(t *testing.T) { } func TestClearSign(t *testing.T) { - signer, err := NewFromFiles(testKeyfile, testPubfile) + signer, err := NewFromFiles(testKeyfile, testPubFile) if err != nil { t.Fatal(err) } - sig, err := signer.ClearSign(testChartfile) + sig, err := signer.ClearSign(testChartFile) if err != nil { t.Fatal(err) } @@ -244,7 +245,7 @@ func (s failSigner) Sign(_ io.Reader, _ []byte, _ crypto.SignerOpts) ([]byte, er } func TestClearSignError(t *testing.T) { - signer, err := NewFromFiles(testKeyfile, testPubfile) + signer, err := NewFromFiles(testKeyfile, testPubFile) if err != nil { t.Fatal(err) } @@ -252,7 +253,7 @@ func TestClearSignError(t *testing.T) { // ensure that signing always fails signer.Entity.PrivateKey.PrivateKey = failSigner{} - sig, err := signer.ClearSign(testChartfile) + sig, err := signer.ClearSign(testChartFile) if err == nil { t.Fatal("didn't get an error from ClearSign but expected one") } @@ -266,12 +267,12 @@ func TestDecodeSignature(t *testing.T) { // Unlike other tests, this does a round-trip test, ensuring that a signature // generated by the library can also be verified by the library. - signer, err := NewFromFiles(testKeyfile, testPubfile) + signer, err := NewFromFiles(testKeyfile, testPubFile) if err != nil { t.Fatal(err) } - sig, err := signer.ClearSign(testChartfile) + sig, err := signer.ClearSign(testChartFile) if err != nil { t.Fatal(err) } @@ -281,14 +282,14 @@ func TestDecodeSignature(t *testing.T) { t.Fatal(err) } - tname := f.Name() + tName := f.Name() defer func() { - os.Remove(tname) + _ = os.Remove(tName) }() - f.WriteString(sig) - f.Close() + _, _ = f.WriteString(sig) + _ = f.Close() - sig2, err := signer.decodeSignature(tname) + sig2, err := signer.decodeSignature(tName) if err != nil { t.Fatal(err) } @@ -304,27 +305,28 @@ func TestDecodeSignature(t *testing.T) { } func TestVerify(t *testing.T) { - signer, err := NewFromFiles(testKeyfile, testPubfile) + signer, err := NewFromFiles(testKeyfile, testPubFile) if err != nil { t.Fatal(err) } - if ver, err := signer.Verify(testChartfile, testSigBlock); err != nil { + if ver, err := signer.Verify(testChartFile, testSigBlock); err != nil { t.Errorf("Failed to pass verify. Err: %s", err) } else if len(ver.FileHash) == 0 { t.Error("Verification is missing hash.") } else if ver.SignedBy == nil { t.Error("No SignedBy field") - } else if ver.FileName != filepath.Base(testChartfile) { + } else if ver.FileName != filepath.Base(testChartFile) { t.Errorf("FileName is unexpectedly %q", ver.FileName) } - if _, err = signer.Verify(testChartfile, testTamperedSigBlock); err == nil { + if _, err = signer.Verify(testChartFile, testTamperedSigBlock); err == nil { t.Errorf("Expected %s to fail.", testTamperedSigBlock) } - switch err.(type) { - case pgperrors.SignatureError: + var signatureError pgperrors.SignatureError + switch { + case errors.As(err, &signatureError): t.Logf("Tampered sig block error: %s (%T)", err, err) default: t.Errorf("Expected invalid signature error, got %q (%T)", err, err) @@ -332,8 +334,8 @@ func TestVerify(t *testing.T) { } // readSumFile reads a file containing a sum generated by the UNIX shasum tool. -func readSumFile(sumfile string) (string, error) { - data, err := os.ReadFile(sumfile) +func readSumFile(sumFile string) (string, error) { + data, err := os.ReadFile(sumFile) if err != nil { return "", err } diff --git a/pkg/registry/client.go b/pkg/registry/client.go index 42f736816..60c74dcee 100644 --- a/pkg/registry/client.go +++ b/pkg/registry/client.go @@ -238,7 +238,7 @@ func (c *Client) Login(host string, options ...LoginOption) error { if err := c.authorizer.LoginWithOpts(authorizerLoginOpts...); err != nil { return err } - fmt.Fprintln(c.out, "Login Succeeded") + _, _ = fmt.Fprintln(c.out, "Login Succeeded") return nil } @@ -282,7 +282,7 @@ func (c *Client) Logout(host string, opts ...LogoutOption) error { if err := c.authorizer.Logout(ctx(c.out, c.debug), host); err != nil { return err } - fmt.Fprintf(c.out, "Removing login credentials for %s\n", host) + _, _ = fmt.Fprintf(c.out, "Removing login credentials for %s\n", host) return nil } @@ -389,7 +389,7 @@ func (c *Client) Pull(ref string, options ...PullOption) (*PullResult, error) { provDescriptor = &d case LegacyChartLayerMediaType: chartDescriptor = &d - fmt.Fprintf(c.out, "Warning: chart media type %s is deprecated\n", LegacyChartLayerMediaType) + _, _ = fmt.Fprintf(c.out, "Warning: chart media type %s is deprecated\n", LegacyChartLayerMediaType) } } if configDescriptor == nil { @@ -471,12 +471,12 @@ func (c *Client) Pull(ref string, options ...PullOption) (*PullResult, error) { } } - fmt.Fprintf(c.out, "Pulled: %s\n", result.Ref) - fmt.Fprintf(c.out, "Digest: %s\n", result.Manifest.Digest) + _, _ = fmt.Fprintf(c.out, "Pulled: %s\n", result.Ref) + _, _ = fmt.Fprintf(c.out, "Digest: %s\n", result.Manifest.Digest) if strings.Contains(result.Ref, "_") { - fmt.Fprintf(c.out, "%s contains an underscore.\n", result.Ref) - fmt.Fprint(c.out, registryUnderscoreMessage+"\n") + _, _ = fmt.Fprintf(c.out, "%s contains an underscore.\n", result.Ref) + _, _ = fmt.Fprint(c.out, registryUnderscoreMessage+"\n") } return result, nil @@ -628,11 +628,11 @@ func (c *Client) Push(data []byte, ref string, options ...PushOption) (*PushResu Size: provDescriptor.Size, } } - fmt.Fprintf(c.out, "Pushed: %s\n", result.Ref) - fmt.Fprintf(c.out, "Digest: %s\n", result.Manifest.Digest) + _, _ = fmt.Fprintf(c.out, "Pushed: %s\n", result.Ref) + _, _ = fmt.Fprintf(c.out, "Digest: %s\n", result.Manifest.Digest) if strings.Contains(parsedRef.Reference, "_") { - fmt.Fprintf(c.out, "%s contains an underscore.\n", result.Ref) - fmt.Fprint(c.out, registryUnderscoreMessage+"\n") + _, _ = fmt.Fprintf(c.out, "%s contains an underscore.\n", result.Ref) + _, _ = fmt.Fprint(c.out, registryUnderscoreMessage+"\n") } return result, err diff --git a/pkg/registry/util.go b/pkg/registry/util.go index 4bff39495..df30b4c6a 100644 --- a/pkg/registry/util.go +++ b/pkg/registry/util.go @@ -44,7 +44,7 @@ var immutableOciAnnotations = []string{ ocispec.AnnotationTitle, } -// IsOCI determines whether or not a URL is to be treated as an OCI URL +// IsOCI determines whether a URL is to be treated as an OCI URL func IsOCI(url string) bool { return strings.HasPrefix(url, fmt.Sprintf("%s://", OCIScheme)) } diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index 970e96da2..4c622c640 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -144,7 +144,7 @@ func (r *ChartRepository) DownloadIndexFile() (string, error) { // Create the chart list file in the cache directory var charts strings.Builder for name := range indexFile.Entries { - fmt.Fprintln(&charts, name) + _, _ = fmt.Fprintln(&charts, name) } chartsFile := filepath.Join(r.CachePath, helmpath.CacheChartsFile(r.Config.Name)) os.MkdirAll(filepath.Dir(chartsFile), 0755)