aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/networks
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman/networks')
-rw-r--r--cmd/podman/networks/create.go10
-rw-r--r--cmd/podman/networks/rm.go12
2 files changed, 8 insertions, 14 deletions
diff --git a/cmd/podman/networks/create.go b/cmd/podman/networks/create.go
index 84c58d4dc..2cf7023f3 100644
--- a/cmd/podman/networks/create.go
+++ b/cmd/podman/networks/create.go
@@ -1,6 +1,7 @@
package network
import (
+ "errors"
"fmt"
"net"
@@ -11,7 +12,6 @@ import (
"github.com/containers/podman/v4/cmd/podman/parse"
"github.com/containers/podman/v4/cmd/podman/registry"
"github.com/containers/podman/v4/pkg/domain/entities"
- "github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
@@ -97,11 +97,11 @@ func networkCreate(cmd *cobra.Command, args []string) error {
var err error
networkCreateOptions.Labels, err = parse.GetAllLabels([]string{}, labels)
if err != nil {
- return errors.Wrap(err, "failed to parse labels")
+ return fmt.Errorf("failed to parse labels: %w", err)
}
networkCreateOptions.Options, err = parse.GetAllLabels([]string{}, opts)
if err != nil {
- return errors.Wrapf(err, "unable to parse options")
+ return fmt.Errorf("unable to parse options: %w", err)
}
network := types.Network{
@@ -181,11 +181,11 @@ func parseRange(iprange string) (*types.LeaseRange, error) {
startIP, err := util.FirstIPInSubnet(subnet)
if err != nil {
- return nil, errors.Wrap(err, "failed to get first ip in range")
+ return nil, fmt.Errorf("failed to get first ip in range: %w", err)
}
lastIP, err := util.LastIPInSubnet(subnet)
if err != nil {
- return nil, errors.Wrap(err, "failed to get last ip in range")
+ return nil, fmt.Errorf("failed to get last ip in range: %w", err)
}
return &types.LeaseRange{
StartIP: startIP,
diff --git a/cmd/podman/networks/rm.go b/cmd/podman/networks/rm.go
index f71f59eea..c2d3f655f 100644
--- a/cmd/podman/networks/rm.go
+++ b/cmd/podman/networks/rm.go
@@ -1,6 +1,7 @@
package network
import (
+ "errors"
"fmt"
"strings"
@@ -10,7 +11,6 @@ import (
"github.com/containers/podman/v4/cmd/podman/utils"
"github.com/containers/podman/v4/libpod/define"
"github.com/containers/podman/v4/pkg/domain/entities"
- "github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
@@ -78,15 +78,9 @@ func networkRm(cmd *cobra.Command, args []string) error {
}
func setExitCode(err error) {
- cause := errors.Cause(err)
- switch {
- case cause == define.ErrNoSuchNetwork:
+ if errors.Is(err, define.ErrNoSuchNetwork) || strings.Contains(err.Error(), define.ErrNoSuchNetwork.Error()) {
registry.SetExitCode(1)
- case strings.Contains(cause.Error(), define.ErrNoSuchNetwork.Error()):
- registry.SetExitCode(1)
- case cause == define.ErrNetworkInUse:
- registry.SetExitCode(2)
- case strings.Contains(cause.Error(), define.ErrNetworkInUse.Error()):
+ } else if errors.Is(err, define.ErrNetworkInUse) || strings.Contains(err.Error(), define.ErrNetworkInUse.Error()) {
registry.SetExitCode(2)
}
}