fix golangci-lint issues

Signed-off-by: Justen Stall <39888103+justenstall@users.noreply.github.com>
pull/13460/head
Justen Stall 5 months ago
parent 065e2eb3eb
commit 3877ec9049
No known key found for this signature in database

@ -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. // HideSecret must be used with dry run. Otherwise, return an error.
if !i.isDryRun() && i.HideSecret { if !i.isDryRun() && i.HideSecret {
slog.Error("hiding Kubernetes secrets requires a dry-run mode") 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 { 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) toBeAdopted, err = existingResourceConflict(resources, rel.Name, rel.Namespace)
} }
if err != nil { 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)
} }
} }

@ -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. // HideSecret must be used with dry run. Otherwise, return an error.
if !u.isDryRun() && u.HideSecret { 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 // 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) toBeUpdated, err = existingResourceConflict(toBeCreated, upgradedRelease.Name, upgradedRelease.Namespace)
} }
if err != nil { 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 { toBeUpdated.Visit(func(r *resource.Info, err error) error {

@ -163,7 +163,7 @@ func LoadFiles(files []*BufferedFile) (*chart.Chart, error) {
} }
if c.Metadata == nil { 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 { if err := c.Validate(); err != nil {

@ -204,7 +204,7 @@ func writeTarContents(out *tar.Writer, c *chart.Chart, prefix string) error {
// Save values.schema.json if it exists // Save values.schema.json if it exists
if c.Schema != nil { if c.Schema != nil {
if !json.Valid(c.Schema) { 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 return err

@ -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) return nil, fmt.Errorf("failed reloading chart after repo update: %w", err)
} }
} else { } 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 { 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 return nil
} }

@ -69,12 +69,12 @@ func (o *pluginUninstallOptions) run(out io.Writer) error {
for _, name := range o.names { for _, name := range o.names {
if found := findPlugin(plugins, name); found != nil { if found := findPlugin(plugins, name); found != nil {
if err := uninstallPlugin(found); err != 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 { } else {
fmt.Fprintf(out, "Uninstalled plugin: %s\n", name) fmt.Fprintf(out, "Uninstalled plugin: %s\n", name)
} }
} else { } 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 { if len(errorPlugins) > 0 {

@ -72,12 +72,12 @@ func (o *pluginUpdateOptions) run(out io.Writer) error {
for _, name := range o.names { for _, name := range o.names {
if found := findPlugin(plugins, name); found != nil { if found := findPlugin(plugins, name); found != nil {
if err := updatePlugin(found); err != 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 { } else {
fmt.Fprintf(out, "Updated plugin: %s\n", name) fmt.Fprintf(out, "Updated plugin: %s\n", name)
} }
} else { } 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 { if len(errorPlugins) > 0 {

@ -199,7 +199,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
} }
if req := ch.Metadata.Dependencies; req != nil { if req := ch.Metadata.Dependencies; req != nil {
if err := action.CheckDependencies(ch, req); err != 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 { if client.DependencyUpdate {
man := &downloader.Manager{ man := &downloader.Manager{
Out: out, Out: out,

@ -64,11 +64,11 @@ func (g *HTTPGetter) get(href string) (*bytes.Buffer, error) {
// with the basic auth is the one being fetched. // with the basic auth is the one being fetched.
u1, err := url.Parse(g.opts.url) u1, err := url.Parse(g.opts.url)
if err != nil { 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) u2, err := url.Parse(href)
if err != nil { 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. // Host on URL (returned from url.Parse) contains the port if present.

@ -184,13 +184,13 @@ func (c *Client) IsReachable() error {
if err == genericclioptions.ErrEmptyConfig { if err == genericclioptions.ErrEmptyConfig {
// re-replace kubernetes ErrEmptyConfig error with a friendly error // re-replace kubernetes ErrEmptyConfig error with a friendly error
// moar workarounds for Kubernetes API breaking. // moar workarounds for Kubernetes API breaking.
return errors.New("Kubernetes cluster unreachable") return errors.New("kubernetes cluster unreachable")
} }
if err != nil { 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 { 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 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 { func copyRequestStreamToWriter(request *rest.Request, podName, containerName string, writer io.Writer) error {
readCloser, err := request.Stream(context.Background()) readCloser, err := request.Stream(context.Background())
if err != nil { 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() defer readCloser.Close()
_, err = io.Copy(writer, readCloser) _, err = io.Copy(writer, readCloser)
if err != nil { 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 return nil
} }

@ -313,7 +313,7 @@ func validateListAnnotations(yamlStruct *K8sYamlStruct, manifest string) error {
for _, i := range m.Items { for _, i := range m.Items {
if _, ok := i.Metadata.Annotations["helm.sh/resource-policy"]; ok { 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")
} }
} }
} }

@ -881,7 +881,7 @@ func (c *Client) ValidateReference(ref, version string, u *url.URL) (*url.URL, e
return nil, err return nil, err
} }
if len(tags) == 0 { 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 // Determine if version provided

@ -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 // extractChartMeta is used to extract a chart metadata from a byte array

Loading…
Cancel
Save