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 <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2025-03-05 14:47:26 +01:00 • committed by Matt Heon
parent 02e8a59774
commit bc37e935ba

View file

@ -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