fix(pkg): errorlint linter

errorlint linter in pkg/cmd

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
pull/31811/head
Matthieu MOREL 5 days ago
parent 9b22aa4e05
commit 259f76a849

@ -488,7 +488,7 @@ func (i *Install) performInstall(rel *release.Release, toBeAdopted kube.Resource
// pre-install hooks
if !i.DisableHooks {
if err := i.cfg.execHook(rel, release.HookPreInstall, i.WaitStrategy, i.WaitOptions, i.Timeout, i.ServerSideApply); err != nil {
return rel, fmt.Errorf("failed pre-install: %s", err)
return rel, fmt.Errorf("failed pre-install: %w", err)
}
}
@ -534,7 +534,7 @@ func (i *Install) performInstall(rel *release.Release, toBeAdopted kube.Resource
if !i.DisableHooks {
if err := i.cfg.execHook(rel, release.HookPostInstall, i.WaitStrategy, i.WaitOptions, i.Timeout, i.ServerSideApply); err != nil {
return rel, fmt.Errorf("failed post-install: %s", err)
return rel, fmt.Errorf("failed post-install: %w", err)
}
}

@ -16,6 +16,7 @@ limitations under the License.
package util
import (
"errors"
"fmt"
"log/slog"
"strings"
@ -44,6 +45,7 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals common.Values,
if len(c) > 0 {
// retrieve value
vv, err := cvals.PathValue(cpath + c)
var errNoValue common.ErrNoValue
if err == nil {
// if not bool, warn
if bv, ok := vv.(bool); ok {
@ -51,7 +53,7 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals common.Values,
break
}
slog.Warn("returned non-bool value", "path", c, "chart", r.Name)
} else if _, ok := err.(common.ErrNoValue); !ok {
} else if !errors.As(err, &errNoValue) {
// this is a real error
slog.Warn("the method PathValue returned error", slog.Any("error", err))
}

@ -16,6 +16,7 @@ limitations under the License.
package cmd
import (
"errors"
"fmt"
"io"
"os"
@ -76,7 +77,8 @@ func newDependencyBuildCmd(out io.Writer) *cobra.Command {
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

@ -18,6 +18,7 @@ package cmd
import (
"bytes"
"context"
"errors"
"fmt"
"io"
"log/slog"
@ -120,7 +121,8 @@ func loadCLIPlugins(baseCmd *cobra.Command, out io.Writer) {
Stderr: os.Stderr,
}
_, err = plug.Invoke(context.Background(), input)
if execErr, ok := err.(*plugin.InvokeExecError); ok {
execErr := &plugin.InvokeExecError{}
if errors.As(err, &execErr) {
return CommandError{
error: execErr.Err,
ExitCode: execErr.ExitCode,

@ -180,7 +180,7 @@ func TestConfigMapQuery(t *testing.T) {
}
_, err = cfgmaps.Query(map[string]string{"name": "notExist"})
if err != ErrReleaseNotFound {
if !errors.Is(err, ErrReleaseNotFound) {
t.Errorf("Expected {%v}, got {%v}", ErrReleaseNotFound, err)
}
}
@ -252,7 +252,7 @@ func TestConfigMapDelete(t *testing.T) {
// perform the delete on a non-existent release
_, err := cfgmaps.Delete("nonexistent")
if err != ErrReleaseNotFound {
if !errors.Is(err, ErrReleaseNotFound) {
t.Fatalf("Expected ErrReleaseNotFound: got {%v}", err)
}

Loading…
Cancel
Save