mirror of
https://github.com/containers/podman.git
synced 2025-11-13 01:29:06 +08:00
Vendor in containers/(storage,image, common, buildah)
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
6
vendor/github.com/containers/common/libnetwork/internal/util/bridge.go
generated
vendored
6
vendor/github.com/containers/common/libnetwork/internal/util/bridge.go
generated
vendored
@@ -1,23 +1,23 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/containers/common/libnetwork/types"
|
||||
"github.com/containers/common/libnetwork/util"
|
||||
"github.com/containers/common/pkg/config"
|
||||
pkgutil "github.com/containers/common/pkg/util"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func CreateBridge(n NetUtil, network *types.Network, usedNetworks []*net.IPNet, subnetPools []config.SubnetPool) error {
|
||||
if network.NetworkInterface != "" {
|
||||
bridges := GetBridgeInterfaceNames(n)
|
||||
if pkgutil.StringInSlice(network.NetworkInterface, bridges) {
|
||||
return errors.Errorf("bridge name %s already in use", network.NetworkInterface)
|
||||
return fmt.Errorf("bridge name %s already in use", network.NetworkInterface)
|
||||
}
|
||||
if !types.NameRegex.MatchString(network.NetworkInterface) {
|
||||
return errors.Wrapf(types.RegexError, "bridge name %s invalid", network.NetworkInterface)
|
||||
return fmt.Errorf("bridge name %s invalid: %w", network.NetworkInterface, types.RegexError)
|
||||
}
|
||||
} else {
|
||||
var err error
|
||||
|
||||
7
vendor/github.com/containers/common/libnetwork/internal/util/create.go
generated
vendored
7
vendor/github.com/containers/common/libnetwork/internal/util/create.go
generated
vendored
@@ -1,8 +1,9 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/containers/common/libnetwork/types"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -22,10 +23,10 @@ func CommonNetworkCreate(n NetUtil, network *types.Network) error {
|
||||
// validate the name when given
|
||||
if network.Name != "" {
|
||||
if !types.NameRegex.MatchString(network.Name) {
|
||||
return errors.Wrapf(types.RegexError, "network name %s invalid", network.Name)
|
||||
return fmt.Errorf("network name %s invalid: %w", network.Name, types.RegexError)
|
||||
}
|
||||
if _, err := n.Network(network.Name); err == nil {
|
||||
return errors.Wrapf(types.ErrNetworkExists, "network name %s already used", network.Name)
|
||||
return fmt.Errorf("network name %s already used: %w", network.Name, types.ErrNetworkExists)
|
||||
}
|
||||
} else {
|
||||
name, err = GetFreeDeviceName(n)
|
||||
|
||||
6
vendor/github.com/containers/common/libnetwork/internal/util/ip.go
generated
vendored
6
vendor/github.com/containers/common/libnetwork/internal/util/ip.go
generated
vendored
@@ -2,9 +2,9 @@ package util
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func incByte(subnet *net.IPNet, idx int, shift uint) error {
|
||||
@@ -31,7 +31,7 @@ func NextSubnet(subnet *net.IPNet) (*net.IPNet, error) {
|
||||
}
|
||||
ones, bits := newSubnet.Mask.Size()
|
||||
if ones == 0 {
|
||||
return nil, errors.Errorf("%s has only one subnet", subnet.String())
|
||||
return nil, fmt.Errorf("%s has only one subnet", subnet.String())
|
||||
}
|
||||
zeroes := uint(bits - ones)
|
||||
shift := zeroes % 8
|
||||
|
||||
7
vendor/github.com/containers/common/libnetwork/internal/util/parse.go
generated
vendored
7
vendor/github.com/containers/common/libnetwork/internal/util/parse.go
generated
vendored
@@ -1,9 +1,8 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// ParseMTU parses the mtu option
|
||||
@@ -16,7 +15,7 @@ func ParseMTU(mtu string) (int, error) {
|
||||
return 0, err
|
||||
}
|
||||
if m < 0 {
|
||||
return 0, errors.Errorf("mtu %d is less than zero", m)
|
||||
return 0, fmt.Errorf("mtu %d is less than zero", m)
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
@@ -31,7 +30,7 @@ func ParseVlan(vlan string) (int, error) {
|
||||
return 0, err
|
||||
}
|
||||
if v < 0 || v > 4094 {
|
||||
return 0, errors.Errorf("vlan ID %d must be between 0 and 4094", v)
|
||||
return 0, fmt.Errorf("vlan ID %d must be between 0 and 4094", v)
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
17
vendor/github.com/containers/common/libnetwork/internal/util/validate.go
generated
vendored
17
vendor/github.com/containers/common/libnetwork/internal/util/validate.go
generated
vendored
@@ -1,11 +1,12 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/containers/common/libnetwork/types"
|
||||
"github.com/containers/common/libnetwork/util"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// ValidateSubnet will validate a given Subnet. It checks if the
|
||||
@@ -25,18 +26,18 @@ func ValidateSubnet(s *types.Subnet, addGateway bool, usedNetworks []*net.IPNet)
|
||||
// the network address and not a random ip in the subnet.
|
||||
_, n, err := net.ParseCIDR(s.Subnet.String())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "subnet invalid")
|
||||
return fmt.Errorf("subnet invalid: %w", err)
|
||||
}
|
||||
|
||||
// check that the new subnet does not conflict with existing ones
|
||||
if NetworkIntersectsWithNetworks(n, usedNetworks) {
|
||||
return errors.Errorf("subnet %s is already used on the host or by another config", n.String())
|
||||
return fmt.Errorf("subnet %s is already used on the host or by another config", n.String())
|
||||
}
|
||||
|
||||
s.Subnet = types.IPNet{IPNet: *n}
|
||||
if s.Gateway != nil {
|
||||
if !s.Subnet.Contains(s.Gateway) {
|
||||
return errors.Errorf("gateway %s not in subnet %s", s.Gateway, &s.Subnet)
|
||||
return fmt.Errorf("gateway %s not in subnet %s", s.Gateway, &s.Subnet)
|
||||
}
|
||||
util.NormalizeIP(&s.Gateway)
|
||||
} else if addGateway {
|
||||
@@ -50,13 +51,13 @@ func ValidateSubnet(s *types.Subnet, addGateway bool, usedNetworks []*net.IPNet)
|
||||
if s.LeaseRange != nil {
|
||||
if s.LeaseRange.StartIP != nil {
|
||||
if !s.Subnet.Contains(s.LeaseRange.StartIP) {
|
||||
return errors.Errorf("lease range start ip %s not in subnet %s", s.LeaseRange.StartIP, &s.Subnet)
|
||||
return fmt.Errorf("lease range start ip %s not in subnet %s", s.LeaseRange.StartIP, &s.Subnet)
|
||||
}
|
||||
util.NormalizeIP(&s.LeaseRange.StartIP)
|
||||
}
|
||||
if s.LeaseRange.EndIP != nil {
|
||||
if !s.Subnet.Contains(s.LeaseRange.EndIP) {
|
||||
return errors.Errorf("lease range end ip %s not in subnet %s", s.LeaseRange.EndIP, &s.Subnet)
|
||||
return fmt.Errorf("lease range end ip %s not in subnet %s", s.LeaseRange.EndIP, &s.Subnet)
|
||||
}
|
||||
util.NormalizeIP(&s.LeaseRange.EndIP)
|
||||
}
|
||||
@@ -107,7 +108,7 @@ func ValidateSetupOptions(n NetUtil, namespacePath string, options types.SetupOp
|
||||
// validatePerNetworkOpts checks that all given static ips are in a subnet on this network
|
||||
func validatePerNetworkOpts(network *types.Network, netOpts *types.PerNetworkOptions) error {
|
||||
if netOpts.InterfaceName == "" {
|
||||
return errors.Errorf("interface name on network %s is empty", network.Name)
|
||||
return fmt.Errorf("interface name on network %s is empty", network.Name)
|
||||
}
|
||||
if network.IPAMOptions[types.Driver] == types.HostLocalIPAMDriver {
|
||||
outer:
|
||||
@@ -117,7 +118,7 @@ func validatePerNetworkOpts(network *types.Network, netOpts *types.PerNetworkOpt
|
||||
continue outer
|
||||
}
|
||||
}
|
||||
return errors.Errorf("requested static ip %s not in any subnet on network %s", ip.String(), network.Name)
|
||||
return fmt.Errorf("requested static ip %s not in any subnet on network %s", ip.String(), network.Name)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user