From 518773a616ea6e29b3f7481564bb69d8ec63268c Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Wed, 5 Mar 2025 14:47:26 +0100 Subject: [PATCH] pkg/domain/infra/abi/play.go: fix two nilness issues The first condition is checking an error where no error is returned and the second is checking even though err == nil was matched above already so we know the error is not nil here. Then also replace os.IsNotExist(err) with errors.Is(err, os.ErrNotExist) as that should be used for new code. This should not change behavior in any way. Signed-off-by: Paul Holzinger --- pkg/domain/infra/abi/play.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go index 4876974a1e..7aa636792b 100644 --- a/pkg/domain/infra/abi/play.go +++ b/pkg/domain/infra/abi/play.go @@ -715,9 +715,6 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY } p := specgen.NewPodSpecGenerator() - if err != nil { - return nil, nil, err - } p, err = entities.ToPodSpecGen(*p, &podOpt) if err != nil { @@ -1632,7 +1629,7 @@ func getBuildFile(imageName string, cwd string) (string, error) { // If the error is not because the file does not exist, take // a mulligan and try Dockerfile. If that also fails, return that // error - if err != nil && !os.IsNotExist(err) { + if !errors.Is(err, os.ErrNotExist) { logrus.Error(err.Error()) } @@ -1642,7 +1639,7 @@ func getBuildFile(imageName string, cwd string) (string, error) { return dockerfilePath, nil } // Strike two - if os.IsNotExist(err) { + if errors.Is(err, os.ErrNotExist) { return "", nil } return "", err