use istio client-go library instead of knative (#1661)
use istio client-go library instead of knative bump kubernetes dependency version change code coverage to codecov
This commit is contained in:
29
vendor/github.com/projectcalico/libcalico-go/lib/ipam/ipam_block.go
generated
vendored
29
vendor/github.com/projectcalico/libcalico-go/lib/ipam/ipam_block.go
generated
vendored
@@ -22,13 +22,18 @@ import (
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/projectcalico/libcalico-go/lib/apis/v3"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
v3 "github.com/projectcalico/libcalico-go/lib/apis/v3"
|
||||
"github.com/projectcalico/libcalico-go/lib/backend/model"
|
||||
cerrors "github.com/projectcalico/libcalico-go/lib/errors"
|
||||
cnet "github.com/projectcalico/libcalico-go/lib/net"
|
||||
)
|
||||
|
||||
// windwowsReservedHandle is the handle used to reserve addresses required for Windows
|
||||
// networking so that workloads do not get assigned these addresses.
|
||||
const windowsReservedHandle = "windows-reserved-IPAM-handle"
|
||||
|
||||
// Wrap the backend AllocationBlock struct so that we can
|
||||
// attach methods to it.
|
||||
type allocationBlock struct {
|
||||
@@ -144,8 +149,25 @@ func (b allocationBlock) numFreeAddresses() int {
|
||||
return len(b.Unallocated)
|
||||
}
|
||||
|
||||
// empty returns true if the block has released all of its assignable addresses,
|
||||
// and returns false if any assignable addresses are in use.
|
||||
func (b allocationBlock) empty() bool {
|
||||
return b.numFreeAddresses() == b.NumAddresses()
|
||||
return b.containsOnlyReservedIPs()
|
||||
}
|
||||
|
||||
// containsOnlyReservedIPs returns true if the block is empty excepted for
|
||||
// expected "reserved" IP addresses.
|
||||
func (b *allocationBlock) containsOnlyReservedIPs() bool {
|
||||
for _, attrIdx := range b.Allocations {
|
||||
if attrIdx == nil {
|
||||
continue
|
||||
}
|
||||
attrs := b.Attributes[*attrIdx]
|
||||
if attrs.AttrPrimary == nil || *attrs.AttrPrimary != windowsReservedHandle {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *allocationBlock) release(addresses []cnet.IP) ([]cnet.IP, map[string]int, error) {
|
||||
@@ -348,7 +370,8 @@ func (b allocationBlock) attributesForIP(ip cnet.IP) (map[string]string, error)
|
||||
// Check if allocated.
|
||||
attrIndex := b.Allocations[ordinal]
|
||||
if attrIndex == nil {
|
||||
return nil, errors.New(fmt.Sprintf("IP %s is not currently assigned in block", ip))
|
||||
log.Debugf("IP %s is not currently assigned in block", ip)
|
||||
return nil, cerrors.ErrorResourceDoesNotExist{Identifier: ip.String(), Err: errors.New("IP is unassigned")}
|
||||
}
|
||||
return b.Attributes[*attrIndex].AttrSecondary, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user