@@ -2,6 +2,7 @@ package network
22
33import (
44 "context"
5+ "errors"
56 "fmt"
67 "io"
78 "net"
@@ -13,7 +14,6 @@ import (
1314 "github.com/docker/cli/opts"
1415 "github.com/docker/docker/api/types/network"
1516 "github.com/docker/docker/client"
16- "github.com/pkg/errors"
1717 "github.com/spf13/cobra"
1818)
1919
@@ -143,7 +143,7 @@ func runCreate(ctx context.Context, apiClient client.NetworkAPIClient, output io
143143//nolint:gocyclo
144144func createIPAMConfig (options ipamOptions ) (* network.IPAM , error ) {
145145 if len (options .subnets ) < len (options .ipRanges ) || len (options .subnets ) < len (options .gateways ) {
146- return nil , errors .Errorf ("every ip-range or gateway must have a corresponding subnet" )
146+ return nil , errors .New ("every ip-range or gateway must have a corresponding subnet" )
147147 }
148148 iData := map [string ]* network.IPAMConfig {}
149149
@@ -159,7 +159,7 @@ func createIPAMConfig(options ipamOptions) (*network.IPAM, error) {
159159 return nil , err
160160 }
161161 if ok1 || ok2 {
162- return nil , errors .Errorf ("multiple overlapping subnet configuration is not supported" )
162+ return nil , errors .New ("multiple overlapping subnet configuration is not supported" )
163163 }
164164 }
165165 iData [s ] = & network.IPAMConfig {Subnet : s , AuxAddress : map [string ]string {}}
@@ -180,14 +180,14 @@ func createIPAMConfig(options ipamOptions) (*network.IPAM, error) {
180180 continue
181181 }
182182 if iData [s ].IPRange != "" {
183- return nil , errors .Errorf ("cannot configure multiple ranges (%s, %s) on the same subnet (%s)" , r , iData [s ].IPRange , s )
183+ return nil , fmt .Errorf ("cannot configure multiple ranges (%s, %s) on the same subnet (%s)" , r , iData [s ].IPRange , s )
184184 }
185185 d := iData [s ]
186186 d .IPRange = r
187187 match = true
188188 }
189189 if ! match {
190- return nil , errors .Errorf ("no matching subnet for range %s" , r )
190+ return nil , fmt .Errorf ("no matching subnet for range %s" , r )
191191 }
192192 }
193193
@@ -203,14 +203,14 @@ func createIPAMConfig(options ipamOptions) (*network.IPAM, error) {
203203 continue
204204 }
205205 if iData [s ].Gateway != "" {
206- return nil , errors .Errorf ("cannot configure multiple gateways (%s, %s) for the same subnet (%s)" , g , iData [s ].Gateway , s )
206+ return nil , fmt .Errorf ("cannot configure multiple gateways (%s, %s) for the same subnet (%s)" , g , iData [s ].Gateway , s )
207207 }
208208 d := iData [s ]
209209 d .Gateway = g
210210 match = true
211211 }
212212 if ! match {
213- return nil , errors .Errorf ("no matching subnet for gateway %s" , g )
213+ return nil , fmt .Errorf ("no matching subnet for gateway %s" , g )
214214 }
215215 }
216216
@@ -229,7 +229,7 @@ func createIPAMConfig(options ipamOptions) (*network.IPAM, error) {
229229 match = true
230230 }
231231 if ! match {
232- return nil , errors .Errorf ("no matching subnet for aux-address %s" , aa )
232+ return nil , fmt .Errorf ("no matching subnet for aux-address %s" , aa )
233233 }
234234 }
235235
@@ -250,7 +250,7 @@ func subnetMatches(subnet, data string) (bool, error) {
250250
251251 _ , s , err := net .ParseCIDR (subnet )
252252 if err != nil {
253- return false , errors . Wrap ( err , "invalid subnet" )
253+ return false , fmt . Errorf ( "invalid subnet: %w" , err )
254254 }
255255
256256 if strings .Contains (data , "/" ) {
0 commit comments