瀏覽代碼

Merge pull request #46170 from akerouanton/daemon-network-replace-pkg-errors

daemon/network.go: Remove github.com/pkg/errors pkg
Sebastiaan van Stijn 1 年之前
父節點
當前提交
0485b8f0fb
共有 1 個文件被更改,包括 10 次插入10 次删除
  1. 10 10
      daemon/network.go

+ 10 - 10
daemon/network.go

@@ -2,6 +2,7 @@ package daemon // import "github.com/docker/docker/daemon"
 
 
 import (
 import (
 	"context"
 	"context"
+	"errors"
 	"fmt"
 	"fmt"
 	"net"
 	"net"
 	"sort"
 	"sort"
@@ -31,7 +32,6 @@ import (
 	"github.com/docker/docker/pkg/plugingetter"
 	"github.com/docker/docker/pkg/plugingetter"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/docker/runconfig"
 	"github.com/docker/go-connections/nat"
 	"github.com/docker/go-connections/nat"
-	"github.com/pkg/errors"
 )
 )
 
 
 // PredefinedNetworkError is returned when user tries to create predefined network that already exists.
 // PredefinedNetworkError is returned when user tries to create predefined network that already exists.
@@ -78,11 +78,11 @@ func (daemon *Daemon) FindNetwork(term string) (*libnetwork.Network, error) {
 	case len(listByFullName) == 1:
 	case len(listByFullName) == 1:
 		return listByFullName[0], nil
 		return listByFullName[0], nil
 	case len(listByFullName) > 1:
 	case len(listByFullName) > 1:
-		return nil, errdefs.InvalidParameter(errors.Errorf("network %s is ambiguous (%d matches found on name)", term, len(listByFullName)))
+		return nil, errdefs.InvalidParameter(fmt.Errorf("network %s is ambiguous (%d matches found on name)", term, len(listByFullName)))
 	case len(listByPartialID) == 1:
 	case len(listByPartialID) == 1:
 		return listByPartialID[0], nil
 		return listByPartialID[0], nil
 	case len(listByPartialID) > 1:
 	case len(listByPartialID) > 1:
-		return nil, errdefs.InvalidParameter(errors.Errorf("network %s is ambiguous (%d matches found based on ID prefix)", term, len(listByPartialID)))
+		return nil, errdefs.InvalidParameter(fmt.Errorf("network %s is ambiguous (%d matches found based on ID prefix)", term, len(listByPartialID)))
 	}
 	}
 
 
 	// Be very careful to change the error type here, the
 	// Be very careful to change the error type here, the
@@ -96,7 +96,7 @@ func (daemon *Daemon) FindNetwork(term string) (*libnetwork.Network, error) {
 func (daemon *Daemon) GetNetworkByID(id string) (*libnetwork.Network, error) {
 func (daemon *Daemon) GetNetworkByID(id string) (*libnetwork.Network, error) {
 	c := daemon.netController
 	c := daemon.netController
 	if c == nil {
 	if c == nil {
-		return nil, errors.Wrap(libnetwork.ErrNoSuchNetwork(id), "netcontroller is nil")
+		return nil, fmt.Errorf("netcontroller is nil: %w", libnetwork.ErrNoSuchNetwork(id))
 	}
 	}
 	return c.NetworkByID(id)
 	return c.NetworkByID(id)
 }
 }
@@ -521,7 +521,7 @@ func (daemon *Daemon) DeleteManagedNetwork(networkID string) error {
 func (daemon *Daemon) DeleteNetwork(networkID string) error {
 func (daemon *Daemon) DeleteNetwork(networkID string) error {
 	n, err := daemon.GetNetworkByID(networkID)
 	n, err := daemon.GetNetworkByID(networkID)
 	if err != nil {
 	if err != nil {
-		return errors.Wrap(err, "could not find network by ID")
+		return fmt.Errorf("could not find network by ID: %w", err)
 	}
 	}
 	return daemon.deleteNetwork(n, false)
 	return daemon.deleteNetwork(n, false)
 }
 }
@@ -543,7 +543,7 @@ func (daemon *Daemon) deleteNetwork(nw *libnetwork.Network, dynamic bool) error
 	}
 	}
 
 
 	if err := nw.Delete(); err != nil {
 	if err := nw.Delete(); err != nil {
-		return errors.Wrap(err, "error while removing network")
+		return fmt.Errorf("error while removing network: %w", err)
 	}
 	}
 
 
 	// If this is not a configuration only network, we need to
 	// If this is not a configuration only network, we need to
@@ -812,19 +812,19 @@ func buildCreateEndpointOptions(c *container.Container, n *libnetwork.Network, e
 			for _, ips := range ipam.LinkLocalIPs {
 			for _, ips := range ipam.LinkLocalIPs {
 				linkIP := net.ParseIP(ips)
 				linkIP := net.ParseIP(ips)
 				if linkIP == nil && ips != "" {
 				if linkIP == nil && ips != "" {
-					return nil, errors.Errorf("Invalid link-local IP address: %s", ipam.LinkLocalIPs)
+					return nil, fmt.Errorf("invalid link-local IP address: %s", ipam.LinkLocalIPs)
 				}
 				}
 				ipList = append(ipList, linkIP)
 				ipList = append(ipList, linkIP)
 			}
 			}
 
 
 			ip := net.ParseIP(ipam.IPv4Address)
 			ip := net.ParseIP(ipam.IPv4Address)
 			if ip == nil && ipam.IPv4Address != "" {
 			if ip == nil && ipam.IPv4Address != "" {
-				return nil, errors.Errorf("Invalid IPv4 address: %s)", ipam.IPv4Address)
+				return nil, fmt.Errorf("invalid IPv4 address: %s", ipam.IPv4Address)
 			}
 			}
 
 
 			ip6 := net.ParseIP(ipam.IPv6Address)
 			ip6 := net.ParseIP(ipam.IPv6Address)
 			if ip6 == nil && ipam.IPv6Address != "" {
 			if ip6 == nil && ipam.IPv6Address != "" {
-				return nil, errors.Errorf("Invalid IPv6 address: %s)", ipam.IPv6Address)
+				return nil, fmt.Errorf("invalid IPv6 address: %s", ipam.IPv6Address)
 			}
 			}
 
 
 			createOptions = append(createOptions, libnetwork.CreateOptionIpam(ip, ip6, ipList, nil))
 			createOptions = append(createOptions, libnetwork.CreateOptionIpam(ip, ip6, ipList, nil))
@@ -925,7 +925,7 @@ func buildCreateEndpointOptions(c *container.Container, n *libnetwork.Network, e
 				portStart, portEnd, err = newP.Range()
 				portStart, portEnd, err = newP.Range()
 			}
 			}
 			if err != nil {
 			if err != nil {
-				return nil, errors.Wrapf(err, "Error parsing HostPort value (%s)", binding.HostPort)
+				return nil, fmt.Errorf("error parsing HostPort value (%s): %w", binding.HostPort, err)
 			}
 			}
 			publishedPorts = append(publishedPorts, networktypes.PortBinding{
 			publishedPorts = append(publishedPorts, networktypes.PortBinding{
 				Proto:       portProto,
 				Proto:       portProto,