aboutsummaryrefslogtreecommitdiff
path: root/pkg/ps/ps.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/ps/ps.go')
-rw-r--r--pkg/ps/ps.go23
1 files changed, 12 insertions, 11 deletions
diff --git a/pkg/ps/ps.go b/pkg/ps/ps.go
index 5fe1b83e2..7fc01de31 100644
--- a/pkg/ps/ps.go
+++ b/pkg/ps/ps.go
@@ -1,6 +1,8 @@
package ps
import (
+ "errors"
+ "fmt"
"os"
"path/filepath"
"regexp"
@@ -16,7 +18,6 @@ import (
psdefine "github.com/containers/podman/v4/pkg/ps/define"
"github.com/containers/storage"
"github.com/containers/storage/types"
- "github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@@ -65,7 +66,7 @@ func GetContainerLists(runtime *libpod.Runtime, options entities.ContainerListOp
for _, con := range cons {
listCon, err := ListContainerBatch(runtime, con, options)
switch {
- case errors.Cause(err) == define.ErrNoSuchCtr:
+ case errors.Is(err, define.ErrNoSuchCtr):
continue
case err != nil:
return nil, err
@@ -108,7 +109,7 @@ func GetExternalContainerLists(runtime *libpod.Runtime) ([]entities.ListContaine
for _, con := range externCons {
listCon, err := ListStorageContainer(runtime, con)
switch {
- case errors.Cause(err) == types.ErrLoadError:
+ case errors.Is(err, types.ErrLoadError):
continue
case err != nil:
return nil, err
@@ -138,19 +139,19 @@ func ListContainerBatch(rt *libpod.Runtime, ctr *libpod.Container, opts entities
batchErr := ctr.Batch(func(c *libpod.Container) error {
if opts.Sync {
if err := c.Sync(); err != nil {
- return errors.Wrapf(err, "unable to update container state from OCI runtime")
+ return fmt.Errorf("unable to update container state from OCI runtime: %w", err)
}
}
conConfig = c.Config()
conState, err = c.State()
if err != nil {
- return errors.Wrapf(err, "unable to obtain container state")
+ return fmt.Errorf("unable to obtain container state: %w", err)
}
exitCode, exited, err = c.ExitCode()
if err != nil {
- return errors.Wrapf(err, "unable to obtain container exit code")
+ return fmt.Errorf("unable to obtain container exit code: %w", err)
}
startedTime, err = c.StartedTime()
if err != nil {
@@ -163,7 +164,7 @@ func ListContainerBatch(rt *libpod.Runtime, ctr *libpod.Container, opts entities
pid, err = c.PID()
if err != nil {
- return errors.Wrapf(err, "unable to obtain container pid")
+ return fmt.Errorf("unable to obtain container pid: %w", err)
}
if !opts.Size && !opts.Namespace {
@@ -237,8 +238,8 @@ func ListContainerBatch(rt *libpod.Runtime, ctr *libpod.Container, opts entities
if opts.Pod && len(conConfig.Pod) > 0 {
podName, err := rt.GetName(conConfig.Pod)
if err != nil {
- if errors.Cause(err) == define.ErrNoSuchCtr {
- return entities.ListContainer{}, errors.Wrapf(define.ErrNoSuchPod, "could not find container %s pod (id %s) in state", conConfig.ID, conConfig.Pod)
+ if errors.Is(err, define.ErrNoSuchCtr) {
+ return entities.ListContainer{}, fmt.Errorf("could not find container %s pod (id %s) in state: %w", conConfig.ID, conConfig.Pod, define.ErrNoSuchPod)
}
return entities.ListContainer{}, err
}
@@ -282,7 +283,7 @@ func ListStorageContainer(rt *libpod.Runtime, ctr storage.Container) (entities.L
buildahCtr, err := rt.IsBuildahContainer(ctr.ID)
if err != nil {
- return ps, errors.Wrapf(err, "error determining buildah container for container %s", ctr.ID)
+ return ps, fmt.Errorf("error determining buildah container for container %s: %w", ctr.ID, err)
}
if buildahCtr {
@@ -311,7 +312,7 @@ func ListStorageContainer(rt *libpod.Runtime, ctr storage.Container) (entities.L
func getNamespaceInfo(path string) (string, error) {
val, err := os.Readlink(path)
if err != nil {
- return "", errors.Wrapf(err, "error getting info from %q", path)
+ return "", fmt.Errorf("error getting info from %q: %w", path, err)
}
return getStrFromSquareBrackets(val), nil
}