From 3877ec9049b18694da05c29481f2b2191cd21802 Mon Sep 17 00:00:00 2001 From: Justen Stall <39888103+justenstall@users.noreply.github.com> Date: Mon, 21 Apr 2025 12:44:40 -0400 Subject: [PATCH] fix golangci-lint issues Signed-off-by: Justen Stall <39888103+justenstall@users.noreply.github.com> --- pkg/action/install.go | 4 ++-- pkg/action/upgrade.go | 4 ++-- pkg/chart/v2/loader/load.go | 2 +- pkg/chart/v2/util/save.go | 2 +- pkg/cmd/install.go | 4 ++-- pkg/cmd/plugin_uninstall.go | 4 ++-- pkg/cmd/plugin_update.go | 4 ++-- pkg/cmd/upgrade.go | 2 +- pkg/getter/httpgetter.go | 4 ++-- pkg/kube/client.go | 10 +++++----- pkg/lint/rules/template.go | 2 +- pkg/registry/client.go | 2 +- pkg/registry/util.go | 2 +- 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/pkg/action/install.go b/pkg/action/install.go index 68e4ccdb8..440f41baa 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -247,7 +247,7 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma // HideSecret must be used with dry run. Otherwise, return an error. if !i.isDryRun() && i.HideSecret { slog.Error("hiding Kubernetes secrets requires a dry-run mode") - return nil, errors.New("Hiding Kubernetes secrets requires a dry-run mode") + return nil, errors.New("hiding Kubernetes secrets requires a dry-run mode") } if err := i.availableName(); err != nil { @@ -365,7 +365,7 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma toBeAdopted, err = existingResourceConflict(resources, rel.Name, rel.Namespace) } if err != nil { - return nil, fmt.Errorf("Unable to continue with install: %w", err) + return nil, fmt.Errorf("unable to continue with install: %w", err) } } diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index ed0905136..e2d2ead69 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -205,7 +205,7 @@ func (u *Upgrade) prepareUpgrade(name string, chart *chart.Chart, vals map[strin // HideSecret must be used with dry run. Otherwise, return an error. if !u.isDryRun() && u.HideSecret { - return nil, nil, errors.New("Hiding Kubernetes secrets requires a dry-run mode") + return nil, nil, errors.New("hiding Kubernetes secrets requires a dry-run mode") } // finds the last non-deleted release with the given name @@ -353,7 +353,7 @@ func (u *Upgrade) performUpgrade(ctx context.Context, originalRelease, upgradedR toBeUpdated, err = existingResourceConflict(toBeCreated, upgradedRelease.Name, upgradedRelease.Namespace) } if err != nil { - return nil, fmt.Errorf("Unable to continue with update: %w", err) + return nil, fmt.Errorf("unable to continue with update: %w", err) } toBeUpdated.Visit(func(r *resource.Info, err error) error { diff --git a/pkg/chart/v2/loader/load.go b/pkg/chart/v2/loader/load.go index 8af743c4f..7838b577f 100644 --- a/pkg/chart/v2/loader/load.go +++ b/pkg/chart/v2/loader/load.go @@ -163,7 +163,7 @@ func LoadFiles(files []*BufferedFile) (*chart.Chart, error) { } if c.Metadata == nil { - return c, errors.New("Chart.yaml file is missing") + return c, errors.New("Chart.yaml file is missing") //nolint:staticcheck } if err := c.Validate(); err != nil { diff --git a/pkg/chart/v2/util/save.go b/pkg/chart/v2/util/save.go index 4b8886aca..624a5b562 100644 --- a/pkg/chart/v2/util/save.go +++ b/pkg/chart/v2/util/save.go @@ -204,7 +204,7 @@ 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 { return err diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go index 51e192602..cbec33a80 100644 --- a/pkg/cmd/install.go +++ b/pkg/cmd/install.go @@ -294,7 +294,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options return nil, fmt.Errorf("failed reloading chart after repo update: %w", err) } } else { - return nil, fmt.Errorf("An error occurred while checking for chart dependencies. You may need to run `helm dependency build` to fetch missing dependencies: %w", err) + return nil, fmt.Errorf("an error occurred while checking for chart dependencies. You may need to run `helm dependency build` to fetch missing dependencies: %w", err) } } } @@ -358,7 +358,7 @@ func validateDryRunOptionFlag(dryRunOptionFlagValue string) error { } } if !isAllowed { - return errors.New("Invalid dry-run flag. Flag must one of the following: false, true, none, client, server") + return errors.New("invalid dry-run flag. Flag must one of the following: false, true, none, client, server") } return nil } diff --git a/pkg/cmd/plugin_uninstall.go b/pkg/cmd/plugin_uninstall.go index 6079e3d97..ec73ad6df 100644 --- a/pkg/cmd/plugin_uninstall.go +++ b/pkg/cmd/plugin_uninstall.go @@ -69,12 +69,12 @@ func (o *pluginUninstallOptions) run(out io.Writer) error { for _, name := range o.names { if found := findPlugin(plugins, name); found != nil { if err := uninstallPlugin(found); err != nil { - errorPlugins = append(errorPlugins, fmt.Errorf("Failed to uninstall plugin %s, got error (%v)", name, err)) + errorPlugins = append(errorPlugins, fmt.Errorf("failed to uninstall plugin %s, got error (%v)", name, err)) } else { fmt.Fprintf(out, "Uninstalled plugin: %s\n", name) } } else { - errorPlugins = append(errorPlugins, fmt.Errorf("Plugin: %s not found", name)) + errorPlugins = append(errorPlugins, fmt.Errorf("plugin: %s not found", name)) } } if len(errorPlugins) > 0 { diff --git a/pkg/cmd/plugin_update.go b/pkg/cmd/plugin_update.go index 546f50ef1..59d884877 100644 --- a/pkg/cmd/plugin_update.go +++ b/pkg/cmd/plugin_update.go @@ -72,12 +72,12 @@ func (o *pluginUpdateOptions) run(out io.Writer) error { for _, name := range o.names { if found := findPlugin(plugins, name); found != nil { if err := updatePlugin(found); err != nil { - errorPlugins = append(errorPlugins, fmt.Errorf("Failed to update plugin %s, got error (%v)", name, err)) + errorPlugins = append(errorPlugins, fmt.Errorf("failed to update plugin %s, got error (%v)", name, err)) } else { fmt.Fprintf(out, "Updated plugin: %s\n", name) } } else { - errorPlugins = append(errorPlugins, fmt.Errorf("Plugin: %s not found", name)) + errorPlugins = append(errorPlugins, fmt.Errorf("plugin: %s not found", name)) } } if len(errorPlugins) > 0 { diff --git a/pkg/cmd/upgrade.go b/pkg/cmd/upgrade.go index eb4dc92c0..b93fa6e64 100644 --- a/pkg/cmd/upgrade.go +++ b/pkg/cmd/upgrade.go @@ -199,7 +199,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } if req := ch.Metadata.Dependencies; req != nil { if err := action.CheckDependencies(ch, req); err != nil { - err = fmt.Errorf("An error occurred while checking for chart dependencies. You may need to run `helm dependency build` to fetch missing dependencies: %w", err) + err = fmt.Errorf("an error occurred while checking for chart dependencies. You may need to run `helm dependency build` to fetch missing dependencies: %w", err) if client.DependencyUpdate { man := &downloader.Manager{ Out: out, diff --git a/pkg/getter/httpgetter.go b/pkg/getter/httpgetter.go index 4348fed27..925df201e 100644 --- a/pkg/getter/httpgetter.go +++ b/pkg/getter/httpgetter.go @@ -64,11 +64,11 @@ func (g *HTTPGetter) get(href string) (*bytes.Buffer, error) { // with the basic auth is the one being fetched. u1, err := url.Parse(g.opts.url) if err != nil { - return nil, fmt.Errorf("Unable to parse getter URL: %w", err) + return nil, fmt.Errorf("unable to parse getter URL: %w", err) } u2, err := url.Parse(href) if err != nil { - return nil, fmt.Errorf("Unable to parse URL getting from: %w", err) + return nil, fmt.Errorf("unable to parse URL getting from: %w", err) } // Host on URL (returned from url.Parse) contains the port if present. diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 7b29bfba4..e8ed9e751 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -184,13 +184,13 @@ func (c *Client) IsReachable() error { if err == genericclioptions.ErrEmptyConfig { // re-replace kubernetes ErrEmptyConfig error with a friendly error // moar workarounds for Kubernetes API breaking. - return errors.New("Kubernetes cluster unreachable") + return errors.New("kubernetes cluster unreachable") } if err != nil { - return fmt.Errorf("Kubernetes cluster unreachable: %w", err) + return fmt.Errorf("kubernetes cluster unreachable: %w", err) } if _, err := client.Discovery().ServerVersion(); err != nil { - return fmt.Errorf("Kubernetes cluster unreachable: %w", err) + return fmt.Errorf("kubernetes cluster unreachable: %w", err) } return nil } @@ -742,12 +742,12 @@ func (c *Client) OutputContainerLogsForPodList(podList *v1.PodList, namespace st func copyRequestStreamToWriter(request *rest.Request, podName, containerName string, writer io.Writer) error { readCloser, err := request.Stream(context.Background()) if err != nil { - return fmt.Errorf("Failed to stream pod logs for pod: %s, container: %s", podName, containerName) + return fmt.Errorf("failed to stream pod logs for pod: %s, container: %s", podName, containerName) } defer readCloser.Close() _, err = io.Copy(writer, readCloser) if err != nil { - return fmt.Errorf("Failed to copy IO from logs for pod: %s, container: %s", podName, containerName) + return fmt.Errorf("failed to copy IO from logs for pod: %s, container: %s", podName, containerName) } return nil } diff --git a/pkg/lint/rules/template.go b/pkg/lint/rules/template.go index 4a8c47db5..135ebf90a 100644 --- a/pkg/lint/rules/template.go +++ b/pkg/lint/rules/template.go @@ -313,7 +313,7 @@ func validateListAnnotations(yamlStruct *K8sYamlStruct, manifest string) error { for _, i := range m.Items { if _, ok := i.Metadata.Annotations["helm.sh/resource-policy"]; ok { - return errors.New("Annotation 'helm.sh/resource-policy' within List objects are ignored") + return errors.New("annotation 'helm.sh/resource-policy' within List objects are ignored") } } } diff --git a/pkg/registry/client.go b/pkg/registry/client.go index 1a58df0e1..2d131dc47 100644 --- a/pkg/registry/client.go +++ b/pkg/registry/client.go @@ -881,7 +881,7 @@ func (c *Client) ValidateReference(ref, version string, u *url.URL) (*url.URL, e return nil, err } if len(tags) == 0 { - return nil, fmt.Errorf("Unable to locate any tags in provided repository: %s", ref) + return nil, fmt.Errorf("unable to locate any tags in provided repository: %s", ref) } // Determine if version provided diff --git a/pkg/registry/util.go b/pkg/registry/util.go index 235edab1d..e63dda43a 100644 --- a/pkg/registry/util.go +++ b/pkg/registry/util.go @@ -86,7 +86,7 @@ func GetTagMatchingVersionOrConstraint(tags []string, versionString string) (str } } - return "", fmt.Errorf("Could not locate a version matching provided version string %s", versionString) + return "", fmt.Errorf("could not locate a version matching provided version string %s", versionString) } // extractChartMeta is used to extract a chart metadata from a byte array