mirror of
https://github.com/containers/podman.git
synced 2025-10-20 12:43:58 +08:00
Vendor in new opencontainers/selinux
Also update vendor of containers/common,buildah,storage,image Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2069586 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
5
vendor/github.com/containers/common/libimage/import.go
generated
vendored
5
vendor/github.com/containers/common/libimage/import.go
generated
vendored
@ -49,15 +49,16 @@ func (r *Runtime) Import(ctx context.Context, path string, options *ImportOption
|
||||
ic = config.ImageConfig
|
||||
}
|
||||
|
||||
hist := []v1.History{
|
||||
history := []v1.History{
|
||||
{Comment: options.CommitMessage},
|
||||
}
|
||||
|
||||
config := v1.Image{
|
||||
Config: ic,
|
||||
History: hist,
|
||||
History: history,
|
||||
OS: options.OS,
|
||||
Architecture: options.Arch,
|
||||
Variant: options.Variant,
|
||||
}
|
||||
|
||||
u, err := url.ParseRequestURI(path)
|
||||
|
232
vendor/github.com/containers/common/libnetwork/cni/cni_conversion.go
generated
vendored
232
vendor/github.com/containers/common/libnetwork/cni/cni_conversion.go
generated
vendored
@ -128,76 +128,76 @@ func findPluginByName(plugins []*libcni.NetworkConfig, name string) bool {
|
||||
// convertIPAMConfToNetwork converts A cni IPAMConfig to libpod network subnets.
|
||||
// It returns an array of subnets and an extra bool if dhcp is configured.
|
||||
func convertIPAMConfToNetwork(network *types.Network, ipam *ipamConfig, confPath string) error {
|
||||
if ipam.PluginType == types.DHCPIPAMDriver {
|
||||
switch ipam.PluginType {
|
||||
case "":
|
||||
network.IPAMOptions[types.Driver] = types.NoneIPAMDriver
|
||||
case types.DHCPIPAMDriver:
|
||||
network.IPAMOptions[types.Driver] = types.DHCPIPAMDriver
|
||||
return nil
|
||||
}
|
||||
case types.HostLocalIPAMDriver:
|
||||
network.IPAMOptions[types.Driver] = types.HostLocalIPAMDriver
|
||||
for _, r := range ipam.Ranges {
|
||||
for _, ipam := range r {
|
||||
s := types.Subnet{}
|
||||
|
||||
if ipam.PluginType != types.HostLocalIPAMDriver {
|
||||
// Do not use types.ParseCIDR() because we want the ip to be
|
||||
// the network address and not a random ip in the sub.
|
||||
_, sub, err := net.ParseCIDR(ipam.Subnet)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.Subnet = types.IPNet{IPNet: *sub}
|
||||
|
||||
// gateway
|
||||
var gateway net.IP
|
||||
if ipam.Gateway != "" {
|
||||
gateway = net.ParseIP(ipam.Gateway)
|
||||
if gateway == nil {
|
||||
return errors.Errorf("failed to parse gateway ip %s", ipam.Gateway)
|
||||
}
|
||||
// convert to 4 byte if ipv4
|
||||
util.NormalizeIP(&gateway)
|
||||
} else if !network.Internal {
|
||||
// only add a gateway address if the network is not internal
|
||||
gateway, err = util.FirstIPInSubnet(sub)
|
||||
if err != nil {
|
||||
return errors.Errorf("failed to get first ip in subnet %s", sub.String())
|
||||
}
|
||||
}
|
||||
s.Gateway = gateway
|
||||
|
||||
var rangeStart net.IP
|
||||
var rangeEnd net.IP
|
||||
if ipam.RangeStart != "" {
|
||||
rangeStart = net.ParseIP(ipam.RangeStart)
|
||||
if rangeStart == nil {
|
||||
return errors.Errorf("failed to parse range start ip %s", ipam.RangeStart)
|
||||
}
|
||||
}
|
||||
if ipam.RangeEnd != "" {
|
||||
rangeEnd = net.ParseIP(ipam.RangeEnd)
|
||||
if rangeEnd == nil {
|
||||
return errors.Errorf("failed to parse range end ip %s", ipam.RangeEnd)
|
||||
}
|
||||
}
|
||||
if rangeStart != nil || rangeEnd != nil {
|
||||
s.LeaseRange = &types.LeaseRange{}
|
||||
s.LeaseRange.StartIP = rangeStart
|
||||
s.LeaseRange.EndIP = rangeEnd
|
||||
}
|
||||
if util.IsIPv6(s.Subnet.IP) {
|
||||
network.IPv6Enabled = true
|
||||
}
|
||||
network.Subnets = append(network.Subnets, s)
|
||||
}
|
||||
}
|
||||
default:
|
||||
// This is not an error. While we only support certain ipam drivers, we
|
||||
// cannot make it fail for unsupported ones. CNI is still able to use them,
|
||||
// just our translation logic cannot convert this into a Network.
|
||||
// For the same reason this is not warning, it would just be annoying for
|
||||
// everyone using a unknown ipam driver.
|
||||
logrus.Infof("unsupported ipam plugin %q in %s", ipam.PluginType, confPath)
|
||||
return nil
|
||||
}
|
||||
|
||||
network.IPAMOptions[types.Driver] = types.HostLocalIPAMDriver
|
||||
for _, r := range ipam.Ranges {
|
||||
for _, ipam := range r {
|
||||
s := types.Subnet{}
|
||||
|
||||
// Do not use types.ParseCIDR() because we want the ip to be
|
||||
// the network address and not a random ip in the sub.
|
||||
_, sub, err := net.ParseCIDR(ipam.Subnet)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.Subnet = types.IPNet{IPNet: *sub}
|
||||
|
||||
// gateway
|
||||
var gateway net.IP
|
||||
if ipam.Gateway != "" {
|
||||
gateway = net.ParseIP(ipam.Gateway)
|
||||
if gateway == nil {
|
||||
return errors.Errorf("failed to parse gateway ip %s", ipam.Gateway)
|
||||
}
|
||||
// convert to 4 byte if ipv4
|
||||
util.NormalizeIP(&gateway)
|
||||
} else if !network.Internal {
|
||||
// only add a gateway address if the network is not internal
|
||||
gateway, err = util.FirstIPInSubnet(sub)
|
||||
if err != nil {
|
||||
return errors.Errorf("failed to get first ip in subnet %s", sub.String())
|
||||
}
|
||||
}
|
||||
s.Gateway = gateway
|
||||
|
||||
var rangeStart net.IP
|
||||
var rangeEnd net.IP
|
||||
if ipam.RangeStart != "" {
|
||||
rangeStart = net.ParseIP(ipam.RangeStart)
|
||||
if rangeStart == nil {
|
||||
return errors.Errorf("failed to parse range start ip %s", ipam.RangeStart)
|
||||
}
|
||||
}
|
||||
if ipam.RangeEnd != "" {
|
||||
rangeEnd = net.ParseIP(ipam.RangeEnd)
|
||||
if rangeEnd == nil {
|
||||
return errors.Errorf("failed to parse range end ip %s", ipam.RangeEnd)
|
||||
}
|
||||
}
|
||||
if rangeStart != nil || rangeEnd != nil {
|
||||
s.LeaseRange = &types.LeaseRange{}
|
||||
s.LeaseRange.StartIP = rangeStart
|
||||
s.LeaseRange.EndIP = rangeEnd
|
||||
}
|
||||
if util.IsIPv6(s.Subnet.IP) {
|
||||
network.IPv6Enabled = true
|
||||
}
|
||||
network.Subnets = append(network.Subnets, s)
|
||||
}
|
||||
network.IPAMOptions[types.Driver] = ipam.PluginType
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -225,10 +225,13 @@ func (n *cniNetwork) createCNIConfigListFromNetwork(network *types.Network, writ
|
||||
var (
|
||||
routes []ipamRoute
|
||||
ipamRanges [][]ipamLocalHostRangeConf
|
||||
ipamConf ipamConfig
|
||||
ipamConf *ipamConfig
|
||||
err error
|
||||
)
|
||||
if len(network.Subnets) > 0 {
|
||||
|
||||
ipamDriver := network.IPAMOptions[types.Driver]
|
||||
switch ipamDriver {
|
||||
case types.HostLocalIPAMDriver:
|
||||
defIpv4Route := false
|
||||
defIpv6Route := false
|
||||
for _, subnet := range network.Subnets {
|
||||
@ -257,46 +260,20 @@ func (n *cniNetwork) createCNIConfigListFromNetwork(network *types.Network, writ
|
||||
routes = append(routes, route)
|
||||
}
|
||||
}
|
||||
ipamConf = newIPAMHostLocalConf(routes, ipamRanges)
|
||||
} else {
|
||||
ipamConf = ipamConfig{PluginType: "dhcp"}
|
||||
conf := newIPAMHostLocalConf(routes, ipamRanges)
|
||||
ipamConf = &conf
|
||||
case types.DHCPIPAMDriver:
|
||||
ipamConf = &ipamConfig{PluginType: "dhcp"}
|
||||
|
||||
case types.NoneIPAMDriver:
|
||||
// do nothing
|
||||
default:
|
||||
return nil, "", errors.Errorf("unsupported ipam driver %q", ipamDriver)
|
||||
}
|
||||
|
||||
vlan := 0
|
||||
mtu := 0
|
||||
vlanPluginMode := ""
|
||||
for k, v := range network.Options {
|
||||
switch k {
|
||||
case "mtu":
|
||||
mtu, err = internalutil.ParseMTU(v)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
case "vlan":
|
||||
vlan, err = internalutil.ParseVlan(v)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
case "mode":
|
||||
switch network.Driver {
|
||||
case types.MacVLANNetworkDriver:
|
||||
if !pkgutil.StringInSlice(v, types.ValidMacVLANModes) {
|
||||
return nil, "", errors.Errorf("unknown macvlan mode %q", v)
|
||||
}
|
||||
case types.IPVLANNetworkDriver:
|
||||
if !pkgutil.StringInSlice(v, types.ValidIPVLANModes) {
|
||||
return nil, "", errors.Errorf("unknown ipvlan mode %q", v)
|
||||
}
|
||||
default:
|
||||
return nil, "", errors.Errorf("cannot set option \"mode\" with driver %q", network.Driver)
|
||||
}
|
||||
vlanPluginMode = v
|
||||
|
||||
default:
|
||||
return nil, "", errors.Errorf("unsupported network option %s", k)
|
||||
}
|
||||
opts, err := parseOptions(network.Options, network.Driver)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
isGateway := true
|
||||
@ -314,7 +291,7 @@ func (n *cniNetwork) createCNIConfigListFromNetwork(network *types.Network, writ
|
||||
|
||||
switch network.Driver {
|
||||
case types.BridgeNetworkDriver:
|
||||
bridge := newHostLocalBridge(network.NetworkInterface, isGateway, ipMasq, mtu, vlan, &ipamConf)
|
||||
bridge := newHostLocalBridge(network.NetworkInterface, isGateway, ipMasq, opts.mtu, opts.vlan, ipamConf)
|
||||
plugins = append(plugins, bridge, newPortMapPlugin(), newFirewallPlugin(), newTuningPlugin())
|
||||
// if we find the dnsname plugin we add configuration for it
|
||||
if hasDNSNamePlugin(n.cniPluginDirs) && network.DNSEnabled {
|
||||
@ -323,10 +300,10 @@ func (n *cniNetwork) createCNIConfigListFromNetwork(network *types.Network, writ
|
||||
}
|
||||
|
||||
case types.MacVLANNetworkDriver:
|
||||
plugins = append(plugins, newVLANPlugin(types.MacVLANNetworkDriver, network.NetworkInterface, vlanPluginMode, mtu, &ipamConf))
|
||||
plugins = append(plugins, newVLANPlugin(types.MacVLANNetworkDriver, network.NetworkInterface, opts.vlanPluginMode, opts.mtu, ipamConf))
|
||||
|
||||
case types.IPVLANNetworkDriver:
|
||||
plugins = append(plugins, newVLANPlugin(types.IPVLANNetworkDriver, network.NetworkInterface, vlanPluginMode, mtu, &ipamConf))
|
||||
plugins = append(plugins, newVLANPlugin(types.IPVLANNetworkDriver, network.NetworkInterface, opts.vlanPluginMode, opts.mtu, ipamConf))
|
||||
|
||||
default:
|
||||
return nil, "", errors.Errorf("driver %q is not supported by cni", network.Driver)
|
||||
@ -402,3 +379,48 @@ func removeMachinePlugin(conf *libcni.NetworkConfigList) *libcni.NetworkConfigLi
|
||||
conf.Plugins = plugins
|
||||
return conf
|
||||
}
|
||||
|
||||
type options struct {
|
||||
vlan int
|
||||
mtu int
|
||||
vlanPluginMode string
|
||||
}
|
||||
|
||||
func parseOptions(networkOptions map[string]string, networkDriver string) (*options, error) {
|
||||
opt := &options{}
|
||||
var err error
|
||||
for k, v := range networkOptions {
|
||||
switch k {
|
||||
case "mtu":
|
||||
opt.mtu, err = internalutil.ParseMTU(v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
case "vlan":
|
||||
opt.vlan, err = internalutil.ParseVlan(v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
case "mode":
|
||||
switch networkDriver {
|
||||
case types.MacVLANNetworkDriver:
|
||||
if !pkgutil.StringInSlice(v, types.ValidMacVLANModes) {
|
||||
return nil, errors.Errorf("unknown macvlan mode %q", v)
|
||||
}
|
||||
case types.IPVLANNetworkDriver:
|
||||
if !pkgutil.StringInSlice(v, types.ValidIPVLANModes) {
|
||||
return nil, errors.Errorf("unknown ipvlan mode %q", v)
|
||||
}
|
||||
default:
|
||||
return nil, errors.Errorf("cannot set option \"mode\" with driver %q", networkDriver)
|
||||
}
|
||||
opt.vlanPluginMode = v
|
||||
|
||||
default:
|
||||
return nil, errors.Errorf("unsupported network option %s", k)
|
||||
}
|
||||
}
|
||||
return opt, nil
|
||||
}
|
||||
|
14
vendor/github.com/containers/common/libnetwork/cni/cni_types.go
generated
vendored
14
vendor/github.com/containers/common/libnetwork/cni/cni_types.go
generated
vendored
@ -145,11 +145,13 @@ func newHostLocalBridge(name string, isGateWay, ipMasq bool, mtu, vlan int, ipam
|
||||
MTU: mtu,
|
||||
HairpinMode: true,
|
||||
Vlan: vlan,
|
||||
IPAM: *ipamConf,
|
||||
}
|
||||
// if we use host-local set the ips cap to ensure we can set static ips via runtime config
|
||||
if ipamConf.PluginType == types.HostLocalIPAMDriver {
|
||||
bridge.Capabilities = caps
|
||||
if ipamConf != nil {
|
||||
bridge.IPAM = *ipamConf
|
||||
// if we use host-local set the ips cap to ensure we can set static ips via runtime config
|
||||
if ipamConf.PluginType == types.HostLocalIPAMDriver {
|
||||
bridge.Capabilities = caps
|
||||
}
|
||||
}
|
||||
return &bridge
|
||||
}
|
||||
@ -259,7 +261,9 @@ func hasDNSNamePlugin(paths []string) bool {
|
||||
func newVLANPlugin(pluginType, device, mode string, mtu int, ipam *ipamConfig) VLANConfig {
|
||||
m := VLANConfig{
|
||||
PluginType: pluginType,
|
||||
IPAM: *ipam,
|
||||
}
|
||||
if ipam != nil {
|
||||
m.IPAM = *ipam
|
||||
}
|
||||
if mtu > 0 {
|
||||
m.MTU = mtu
|
||||
|
45
vendor/github.com/containers/common/libnetwork/cni/config.go
generated
vendored
45
vendor/github.com/containers/common/libnetwork/cni/config.go
generated
vendored
@ -53,6 +53,11 @@ func (n *cniNetwork) networkCreate(newNetwork *types.Network, defaultNet bool) (
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = validateIPAMDriver(newNetwork)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Only get the used networks for validation if we do not create the default network.
|
||||
// The default network should not be validated against used subnets, we have to ensure
|
||||
// that this network can always be created even when a subnet is already used on the host.
|
||||
@ -91,6 +96,9 @@ func (n *cniNetwork) networkCreate(newNetwork *types.Network, defaultNet bool) (
|
||||
// generate the network ID
|
||||
newNetwork.ID = getNetworkIDFromName(newNetwork.Name)
|
||||
|
||||
// when we do not have ipam we must disable dns
|
||||
internalutil.IpamNoneDisableDns(newNetwork)
|
||||
|
||||
// FIXME: Should this be a hard error?
|
||||
if newNetwork.DNSEnabled && newNetwork.Internal && hasDNSNamePlugin(n.cniPluginDirs) {
|
||||
logrus.Warnf("dnsname and internal networks are incompatible. dnsname plugin not configured for network %s", newNetwork.Name)
|
||||
@ -197,13 +205,38 @@ func createIPMACVLAN(network *types.Network) error {
|
||||
return errors.Errorf("parent interface %s does not exist", network.NetworkInterface)
|
||||
}
|
||||
}
|
||||
if len(network.Subnets) == 0 {
|
||||
network.IPAMOptions[types.Driver] = types.DHCPIPAMDriver
|
||||
if network.Internal {
|
||||
return errors.New("internal is not supported with macvlan and dhcp ipam driver")
|
||||
|
||||
switch network.IPAMOptions[types.Driver] {
|
||||
// set default
|
||||
case "":
|
||||
if len(network.Subnets) == 0 {
|
||||
// if no subnets and no driver choose dhcp
|
||||
network.IPAMOptions[types.Driver] = types.DHCPIPAMDriver
|
||||
} else {
|
||||
network.IPAMOptions[types.Driver] = types.HostLocalIPAMDriver
|
||||
}
|
||||
} else {
|
||||
network.IPAMOptions[types.Driver] = types.HostLocalIPAMDriver
|
||||
case types.HostLocalIPAMDriver:
|
||||
if len(network.Subnets) == 0 {
|
||||
return errors.New("host-local ipam driver set but no subnets are given")
|
||||
}
|
||||
}
|
||||
|
||||
if network.IPAMOptions[types.Driver] == types.DHCPIPAMDriver && network.Internal {
|
||||
return errors.New("internal is not supported with macvlan and dhcp ipam driver")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateIPAMDriver(n *types.Network) error {
|
||||
ipamDriver := n.IPAMOptions[types.Driver]
|
||||
switch ipamDriver {
|
||||
case "", types.HostLocalIPAMDriver:
|
||||
case types.DHCPIPAMDriver, types.NoneIPAMDriver:
|
||||
if len(n.Subnets) > 0 {
|
||||
return errors.Errorf("%s ipam driver is set but subnets are given", ipamDriver)
|
||||
}
|
||||
default:
|
||||
return errors.Errorf("unsupported ipam driver %q", ipamDriver)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
45
vendor/github.com/containers/common/libnetwork/cni/run.go
generated
vendored
45
vendor/github.com/containers/common/libnetwork/cni/run.go
generated
vendored
@ -125,35 +125,38 @@ func CNIResultToStatus(res cnitypes.Result) (types.StatusBlock, error) {
|
||||
result.DNSSearchDomains = cniResult.DNS.Search
|
||||
|
||||
interfaces := make(map[string]types.NetInterface)
|
||||
for _, ip := range cniResult.IPs {
|
||||
if ip.Interface == nil {
|
||||
// we do no expect ips without an interface
|
||||
for intIndex, netInterface := range cniResult.Interfaces {
|
||||
// we are only interested about interfaces in the container namespace
|
||||
if netInterface.Sandbox == "" {
|
||||
continue
|
||||
}
|
||||
if len(cniResult.Interfaces) <= *ip.Interface {
|
||||
return result, errors.Errorf("invalid cni result, interface index %d out of range", *ip.Interface)
|
||||
|
||||
mac, err := net.ParseMAC(netInterface.Mac)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
cniInt := cniResult.Interfaces[*ip.Interface]
|
||||
netInt, ok := interfaces[cniInt.Name]
|
||||
if ok {
|
||||
netInt.Subnets = append(netInt.Subnets, types.NetAddress{
|
||||
IPNet: types.IPNet{IPNet: ip.Address},
|
||||
Gateway: ip.Gateway,
|
||||
})
|
||||
interfaces[cniInt.Name] = netInt
|
||||
} else {
|
||||
mac, err := net.ParseMAC(cniInt.Mac)
|
||||
if err != nil {
|
||||
return result, err
|
||||
subnets := make([]types.NetAddress, 0, len(cniResult.IPs))
|
||||
for _, ip := range cniResult.IPs {
|
||||
if ip.Interface == nil {
|
||||
// we do no expect ips without an interface
|
||||
continue
|
||||
}
|
||||
interfaces[cniInt.Name] = types.NetInterface{
|
||||
MacAddress: types.HardwareAddr(mac),
|
||||
Subnets: []types.NetAddress{{
|
||||
if len(cniResult.Interfaces) <= *ip.Interface {
|
||||
return result, errors.Errorf("invalid cni result, interface index %d out of range", *ip.Interface)
|
||||
}
|
||||
|
||||
// when we have a ip for this interface add it to the subnets
|
||||
if *ip.Interface == intIndex {
|
||||
subnets = append(subnets, types.NetAddress{
|
||||
IPNet: types.IPNet{IPNet: ip.Address},
|
||||
Gateway: ip.Gateway,
|
||||
}},
|
||||
})
|
||||
}
|
||||
}
|
||||
interfaces[netInterface.Name] = types.NetInterface{
|
||||
MacAddress: types.HardwareAddr(mac),
|
||||
Subnets: subnets,
|
||||
}
|
||||
}
|
||||
result.Interfaces = interfaces
|
||||
return result, nil
|
||||
|
4
vendor/github.com/containers/common/libnetwork/internal/util/bridge.go
generated
vendored
4
vendor/github.com/containers/common/libnetwork/internal/util/bridge.go
generated
vendored
@ -27,7 +27,9 @@ func CreateBridge(n NetUtil, network *types.Network, usedNetworks []*net.IPNet,
|
||||
}
|
||||
}
|
||||
|
||||
if network.IPAMOptions[types.Driver] != types.DHCPIPAMDriver {
|
||||
ipamDriver := network.IPAMOptions[types.Driver]
|
||||
// also do this when the driver is unset
|
||||
if ipamDriver == "" || ipamDriver == types.HostLocalIPAMDriver {
|
||||
if len(network.Subnets) == 0 {
|
||||
freeSubnet, err := GetFreeIPv4NetworkSubnet(usedNetworks, subnetPools)
|
||||
if err != nil {
|
||||
|
8
vendor/github.com/containers/common/libnetwork/internal/util/create.go
generated
vendored
8
vendor/github.com/containers/common/libnetwork/internal/util/create.go
generated
vendored
@ -3,6 +3,7 @@ package util
|
||||
import (
|
||||
"github.com/containers/common/libnetwork/types"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func CommonNetworkCreate(n NetUtil, network *types.Network) error {
|
||||
@ -39,3 +40,10 @@ func CommonNetworkCreate(n NetUtil, network *types.Network) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func IpamNoneDisableDns(network *types.Network) {
|
||||
if network.IPAMOptions[types.Driver] == types.NoneIPAMDriver {
|
||||
logrus.Debugf("dns disabled for network %q because ipam driver is set to none", network.Name)
|
||||
network.DNSEnabled = false
|
||||
}
|
||||
}
|
||||
|
41
vendor/github.com/containers/common/libnetwork/netavark/config.go
generated
vendored
41
vendor/github.com/containers/common/libnetwork/netavark/config.go
generated
vendored
@ -67,6 +67,11 @@ func (n *netavarkNetwork) networkCreate(newNetwork *types.Network, defaultNet bo
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = validateIPAMDriver(newNetwork)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Only get the used networks for validation if we do not create the default network.
|
||||
// The default network should not be validated against used subnets, we have to ensure
|
||||
// that this network can always be created even when a subnet is already used on the host.
|
||||
@ -116,7 +121,10 @@ func (n *netavarkNetwork) networkCreate(newNetwork *types.Network, defaultNet bo
|
||||
return nil, errors.Wrapf(types.ErrInvalidArg, "unsupported driver %s", newNetwork.Driver)
|
||||
}
|
||||
|
||||
// add gatway when not internal or dns enabled
|
||||
// when we do not have ipam we must disable dns
|
||||
internalutil.IpamNoneDisableDns(newNetwork)
|
||||
|
||||
// add gateway when not internal or dns enabled
|
||||
addGateway := !newNetwork.Internal || newNetwork.DNSEnabled
|
||||
err = internalutil.ValidateSubnets(newNetwork, addGateway, usedNetworks)
|
||||
if err != nil {
|
||||
@ -153,10 +161,19 @@ func createMacvlan(network *types.Network) error {
|
||||
return errors.Errorf("parent interface %s does not exist", network.NetworkInterface)
|
||||
}
|
||||
}
|
||||
if len(network.Subnets) == 0 {
|
||||
return errors.Errorf("macvlan driver needs at least one subnet specified, DHCP is not supported with netavark")
|
||||
|
||||
// we already validated the drivers before so we just have to set the default here
|
||||
switch network.IPAMOptions[types.Driver] {
|
||||
case "":
|
||||
if len(network.Subnets) == 0 {
|
||||
return errors.Errorf("macvlan driver needs at least one subnet specified, DHCP is not yet supported with netavark")
|
||||
}
|
||||
network.IPAMOptions[types.Driver] = types.HostLocalIPAMDriver
|
||||
case types.HostLocalIPAMDriver:
|
||||
if len(network.Subnets) == 0 {
|
||||
return errors.Errorf("macvlan driver needs at least one subnet specified, when the host-local ipam driver is set")
|
||||
}
|
||||
}
|
||||
network.IPAMOptions[types.Driver] = types.HostLocalIPAMDriver
|
||||
|
||||
// validate the given options, we do not need them but just check to make sure they are valid
|
||||
for key, value := range network.Options {
|
||||
@ -246,3 +263,19 @@ func (n *netavarkNetwork) NetworkInspect(nameOrID string) (types.Network, error)
|
||||
}
|
||||
return *network, nil
|
||||
}
|
||||
|
||||
func validateIPAMDriver(n *types.Network) error {
|
||||
ipamDriver := n.IPAMOptions[types.Driver]
|
||||
switch ipamDriver {
|
||||
case "", types.HostLocalIPAMDriver:
|
||||
case types.NoneIPAMDriver:
|
||||
if len(n.Subnets) > 0 {
|
||||
return errors.New("none ipam driver is set but subnets are given")
|
||||
}
|
||||
case types.DHCPIPAMDriver:
|
||||
return errors.New("dhcp ipam driver is not yet supported with netavark")
|
||||
default:
|
||||
return errors.Errorf("unsupported ipam driver %q", ipamDriver)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
2
vendor/github.com/containers/common/libnetwork/netavark/network.go
generated
vendored
2
vendor/github.com/containers/common/libnetwork/netavark/network.go
generated
vendored
@ -245,7 +245,7 @@ func parseNetwork(network *types.Network) error {
|
||||
return errors.Errorf("invalid network ID %q", network.ID)
|
||||
}
|
||||
|
||||
// add gatway when not internal or dns enabled
|
||||
// add gateway when not internal or dns enabled
|
||||
addGateway := !network.Internal || network.DNSEnabled
|
||||
return util.ValidateSubnets(network, addGateway, nil)
|
||||
}
|
||||
|
4
vendor/github.com/containers/common/libnetwork/types/const.go
generated
vendored
4
vendor/github.com/containers/common/libnetwork/types/const.go
generated
vendored
@ -12,10 +12,12 @@ const (
|
||||
|
||||
// IPAM drivers
|
||||
Driver = "driver"
|
||||
// HostLocalIPAMDriver store the ip
|
||||
// HostLocalIPAMDriver store the ip locally in a db
|
||||
HostLocalIPAMDriver = "host-local"
|
||||
// DHCPIPAMDriver get subnet and ip from dhcp server
|
||||
DHCPIPAMDriver = "dhcp"
|
||||
// NoneIPAMDriver do not provide ipam management
|
||||
NoneIPAMDriver = "none"
|
||||
|
||||
// DefaultSubnet is the name that will be used for the default CNI network.
|
||||
DefaultNetworkName = "podman"
|
||||
|
12
vendor/github.com/containers/common/pkg/config/config.go
generated
vendored
12
vendor/github.com/containers/common/pkg/config/config.go
generated
vendored
@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@ -251,7 +252,7 @@ type EngineConfig struct {
|
||||
|
||||
// EventsLogFileMaxSize sets the maximum size for the events log. When the limit is exceeded,
|
||||
// the logfile is rotated and the old one is deleted.
|
||||
EventsLogFileMaxSize uint64 `toml:"events_logfile_max_size,omitempty"`
|
||||
EventsLogFileMaxSize uint64 `toml:"events_logfile_max_size,omitempty,omitzero"`
|
||||
|
||||
// EventsLogger determines where events should be logged.
|
||||
EventsLogger string `toml:"events_logger,omitempty"`
|
||||
@ -649,17 +650,14 @@ func readConfigFromFile(path string, config *Config) error {
|
||||
func addConfigs(dirPath string, configs []string) ([]string, error) {
|
||||
newConfigs := []string{}
|
||||
|
||||
err := filepath.Walk(dirPath,
|
||||
err := filepath.WalkDir(dirPath,
|
||||
// WalkFunc to read additional configs
|
||||
func(path string, info os.FileInfo, err error) error {
|
||||
func(path string, d fs.DirEntry, err error) error {
|
||||
switch {
|
||||
case err != nil:
|
||||
// return error (could be a permission problem)
|
||||
return err
|
||||
case info == nil:
|
||||
// this should only happen when err != nil but let's be sure
|
||||
return nil
|
||||
case info.IsDir():
|
||||
case d.IsDir():
|
||||
if path != dirPath {
|
||||
// make sure to not recurse into sub-directories
|
||||
return filepath.SkipDir
|
||||
|
4
vendor/github.com/containers/common/pkg/report/camelcase/README.md
generated
vendored
4
vendor/github.com/containers/common/pkg/report/camelcase/README.md
generated
vendored
@ -27,9 +27,9 @@ go get github.com/fatih/camelcase
|
||||
## Usage and examples
|
||||
|
||||
```go
|
||||
splitted := camelcase.Split("GolangPackage")
|
||||
split := camelcase.Split("GolangPackage")
|
||||
|
||||
fmt.Println(splitted[0], splitted[1]) // prints: "Golang", "Package"
|
||||
fmt.Println(split[0], split[1]) // prints: "Golang", "Package"
|
||||
```
|
||||
|
||||
Both lower camel case and upper camel case are supported. For more info please
|
||||
|
8
vendor/github.com/containers/common/pkg/secrets/passdriver/passdriver.go
generated
vendored
8
vendor/github.com/containers/common/pkg/secrets/passdriver/passdriver.go
generated
vendored
@ -30,6 +30,8 @@ type driverConfig struct {
|
||||
Root string
|
||||
// KeyID contains the key id that will be used for encryption (i.e. user@domain.tld)
|
||||
KeyID string
|
||||
// GPGHomedir is the homedir where the GPG keys are stored
|
||||
GPGHomedir string
|
||||
}
|
||||
|
||||
func (cfg *driverConfig) ParseOpts(opts map[string]string) {
|
||||
@ -40,6 +42,9 @@ func (cfg *driverConfig) ParseOpts(opts map[string]string) {
|
||||
if val, ok := opts["key"]; ok {
|
||||
cfg.KeyID = val
|
||||
}
|
||||
if val, ok := opts["gpghomedir"]; ok {
|
||||
cfg.GPGHomedir = val
|
||||
}
|
||||
}
|
||||
|
||||
func defaultDriverConfig() *driverConfig {
|
||||
@ -156,6 +161,9 @@ func (d *Driver) Delete(id string) error {
|
||||
}
|
||||
|
||||
func (d *Driver) gpg(ctx context.Context, in io.Reader, out io.Writer, args ...string) error {
|
||||
if d.GPGHomedir != "" {
|
||||
args = append([]string{"--homedir", d.GPGHomedir}, args...)
|
||||
}
|
||||
cmd := exec.CommandContext(ctx, "gpg", args...)
|
||||
cmd.Env = os.Environ()
|
||||
cmd.Stdin = in
|
||||
|
Reference in New Issue
Block a user