summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/ports.go9
-rw-r--r--utils/utils.go9
-rw-r--r--utils/utils_supported.go7
-rw-r--r--utils/utils_windows.go2
4 files changed, 12 insertions, 15 deletions
diff --git a/utils/ports.go b/utils/ports.go
index 57a6f8275..eea060433 100644
--- a/utils/ports.go
+++ b/utils/ports.go
@@ -1,26 +1,25 @@
package utils
import (
+ "fmt"
"net"
"strconv"
-
- "github.com/pkg/errors"
)
// Find a random, open port on the host.
func GetRandomPort() (int, error) {
l, err := net.Listen("tcp", ":0")
if err != nil {
- return 0, errors.Wrapf(err, "unable to get free TCP port")
+ return 0, fmt.Errorf("unable to get free TCP port: %w", err)
}
defer l.Close()
_, randomPort, err := net.SplitHostPort(l.Addr().String())
if err != nil {
- return 0, errors.Wrapf(err, "unable to determine free port")
+ return 0, fmt.Errorf("unable to determine free port: %w", err)
}
rp, err := strconv.Atoi(randomPort)
if err != nil {
- return 0, errors.Wrapf(err, "unable to convert random port to int")
+ return 0, fmt.Errorf("unable to convert random port to int: %w", err)
}
return rp, nil
}
diff --git a/utils/utils.go b/utils/utils.go
index 9239cf907..a20181b0a 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -16,7 +16,6 @@ import (
"github.com/containers/podman/v4/libpod/define"
"github.com/containers/storage/pkg/archive"
"github.com/godbus/dbus/v5"
- "github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@@ -114,7 +113,7 @@ func UntarToFileSystem(dest string, tarball *os.File, options *archive.TarOption
func CreateTarFromSrc(source string, dest string) error {
file, err := os.Create(dest)
if err != nil {
- return errors.Wrapf(err, "Could not create tarball file '%s'", dest)
+ return fmt.Errorf("could not create tarball file '%s': %w", dest, err)
}
defer file.Close()
return TarToFilesystem(source, file)
@@ -154,7 +153,7 @@ func RemoveScientificNotationFromFloat(x float64) (float64, error) {
}
result, err := strconv.ParseFloat(bigNum, 64)
if err != nil {
- return x, errors.Wrapf(err, "unable to remove scientific number from calculations")
+ return x, fmt.Errorf("unable to remove scientific number from calculations: %w", err)
}
return result, nil
}
@@ -181,11 +180,11 @@ func moveProcessPIDFileToScope(pidPath, slice, scope string) error {
if os.IsNotExist(err) {
return nil
}
- return errors.Wrapf(err, "cannot read pid file %s", pidPath)
+ return fmt.Errorf("cannot read pid file %s: %w", pidPath, err)
}
pid, err := strconv.ParseUint(string(data), 10, 0)
if err != nil {
- return errors.Wrapf(err, "cannot parse pid file %s", pidPath)
+ return fmt.Errorf("cannot parse pid file %s: %w", pidPath, err)
}
return moveProcessToScope(int(pid), slice, scope)
diff --git a/utils/utils_supported.go b/utils/utils_supported.go
index 6378212b6..d7d47b2bc 100644
--- a/utils/utils_supported.go
+++ b/utils/utils_supported.go
@@ -17,7 +17,6 @@ import (
"github.com/containers/podman/v4/pkg/rootless"
systemdDbus "github.com/coreos/go-systemd/v22/dbus"
"github.com/godbus/dbus/v5"
- "github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@@ -77,7 +76,7 @@ func getCgroupProcess(procFile string, allowRoot bool) (string, error) {
line := scanner.Text()
parts := strings.SplitN(line, ":", 3)
if len(parts) != 3 {
- return "", errors.Errorf("cannot parse cgroup line %q", line)
+ return "", fmt.Errorf("cannot parse cgroup line %q", line)
}
if strings.HasPrefix(line, "0::") {
cgroup = line[3:]
@@ -88,7 +87,7 @@ func getCgroupProcess(procFile string, allowRoot bool) (string, error) {
}
}
if len(cgroup) == 0 || (!allowRoot && cgroup == "/") {
- return "", errors.Errorf("could not find cgroup mount in %q", procFile)
+ return "", fmt.Errorf("could not find cgroup mount in %q", procFile)
}
return cgroup, nil
}
@@ -133,7 +132,7 @@ func moveUnderCgroup(cgroup, subtree string, processes []uint32) error {
line := scanner.Text()
parts := strings.SplitN(line, ":", 3)
if len(parts) != 3 {
- return errors.Errorf("cannot parse cgroup line %q", line)
+ return fmt.Errorf("cannot parse cgroup line %q", line)
}
// root cgroup, skip it
diff --git a/utils/utils_windows.go b/utils/utils_windows.go
index 1d017f5ae..18f232116 100644
--- a/utils/utils_windows.go
+++ b/utils/utils_windows.go
@@ -3,7 +3,7 @@
package utils
-import "github.com/pkg/errors"
+import "errors"
func RunUnderSystemdScope(pid int, slice string, unitName string) error {
return errors.New("not implemented for windows")