[v3.2] Add grafana dashboard importing API (#11)
* Add API to import grafana templates to kubesphere dashboard * Merge and fix the latest codes from kubesphere #2501 Signed-off-by: zhu733756 <talonzhu@yunify.com>
This commit is contained in:
23
vendor/kubesphere.io/api/network/v1alpha1/doc.go
generated
vendored
Normal file
23
vendor/kubesphere.io/api/network/v1alpha1/doc.go
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
Copyright 2019 The KubeSphere authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package v1alpha1 contains API Schema definitions for the network v1alpha1 API group
|
||||
// +k8s:openapi-gen=true
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
// +k8s:conversion-gen=kubesphere.io/api/network
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +groupName=network.kubesphere.io
|
||||
package v1alpha1
|
||||
340
vendor/kubesphere.io/api/network/v1alpha1/ipamblock_types.go
generated
vendored
Normal file
340
vendor/kubesphere.io/api/network/v1alpha1/ipamblock_types.go
generated
vendored
Normal file
@@ -0,0 +1,340 @@
|
||||
/*
|
||||
Copyright 2020 The KubeSphere authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/projectcalico/libcalico-go/lib/names"
|
||||
cnet "github.com/projectcalico/libcalico-go/lib/net"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
ResourceKindIPAMBlock = "IPAMBlock"
|
||||
ResourceSingularIPAMBlock = "ipamblock"
|
||||
ResourcePluralIPAMBlock = "ipamblocks"
|
||||
|
||||
IPAMBlockAttributePod = "pod"
|
||||
IPAMBlockAttributeVm = "vm"
|
||||
IPAMBlockAttributeWorkloadType = "workload-type"
|
||||
IPAMBlockAttributeNamespace = "namespace"
|
||||
IPAMBlockAttributeWorkspace = "workspace"
|
||||
IPAMBlockAttributeNode = "node"
|
||||
IPAMBlockAttributePool = "pool-name"
|
||||
IPAMBlockAttributeType = "pool-type"
|
||||
|
||||
ReservedHandle = "kubesphere-reserved-handle"
|
||||
ReservedNote = "kubesphere reserved"
|
||||
)
|
||||
|
||||
// +genclient
|
||||
// +genclient:nonNamespaced
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +k8s:openapi-gen=true
|
||||
// +kubebuilder:resource:scope=Cluster
|
||||
type IPAMBlock struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
// Specification of the IPAMBlock.
|
||||
Spec IPAMBlockSpec `json:"spec,omitempty"`
|
||||
}
|
||||
|
||||
// IPAMBlockSpec contains the specification for an IPAMBlock resource.
|
||||
type IPAMBlockSpec struct {
|
||||
ID uint32 `json:"id"`
|
||||
CIDR string `json:"cidr"`
|
||||
Allocations []*int `json:"allocations"`
|
||||
Unallocated []int `json:"unallocated"`
|
||||
Attributes []AllocationAttribute `json:"attributes"`
|
||||
Deleted bool `json:"deleted"`
|
||||
}
|
||||
|
||||
type AllocationAttribute struct {
|
||||
AttrPrimary string `json:"handle_id,omitempty"`
|
||||
AttrSecondary map[string]string `json:"secondary,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +genclient:nonNamespaced
|
||||
type IPAMBlockList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata"`
|
||||
Items []IPAMBlock `json:"items"`
|
||||
}
|
||||
|
||||
// The caller needs to check that the returned slice length is correct.
|
||||
func (b *IPAMBlock) AutoAssign(
|
||||
num int, handleID string, attrs map[string]string) []cnet.IPNet {
|
||||
|
||||
// Walk the allocations until we find enough addresses.
|
||||
ordinals := []int{}
|
||||
for len(b.Spec.Unallocated) > 0 && len(ordinals) < num {
|
||||
ordinals = append(ordinals, b.Spec.Unallocated[0])
|
||||
b.Spec.Unallocated = b.Spec.Unallocated[1:]
|
||||
}
|
||||
|
||||
// Create slice of IPs and perform the allocations.
|
||||
ips := []cnet.IPNet{}
|
||||
ip, mask, _ := cnet.ParseCIDR(b.Spec.CIDR)
|
||||
for _, o := range ordinals {
|
||||
attrIndex := b.findOrAddAttribute(handleID, attrs)
|
||||
b.Spec.Allocations[o] = &attrIndex
|
||||
ipNets := cnet.IPNet(*mask)
|
||||
ipNets.IP = cnet.IncrementIP(*ip, big.NewInt(int64(o))).IP
|
||||
ips = append(ips, ipNets)
|
||||
}
|
||||
|
||||
return ips
|
||||
}
|
||||
|
||||
func (b *IPAMBlock) String() string {
|
||||
return fmt.Sprintf("%d-%s", b.Spec.ID, b.Spec.CIDR)
|
||||
}
|
||||
|
||||
func (b *IPAMBlock) ID() uint32 {
|
||||
return b.Spec.ID
|
||||
}
|
||||
|
||||
func (b *IPAMBlock) BlockName() string {
|
||||
_, cidr, _ := cnet.ParseCIDR(b.Spec.CIDR)
|
||||
return fmt.Sprintf("%d-%s", b.ID(), names.CIDRToName(*cidr))
|
||||
}
|
||||
|
||||
// Get number of addresses covered by the block
|
||||
func (b *IPAMBlock) NumAddresses() int {
|
||||
_, cidr, _ := cnet.ParseCIDR(b.Spec.CIDR)
|
||||
ones, size := cidr.Mask.Size()
|
||||
numAddresses := 1 << uint(size-ones)
|
||||
return numAddresses
|
||||
}
|
||||
|
||||
// Find the ordinal (i.e. how far into the block) a given IP lies. Returns an error if the IP is outside the block.
|
||||
func (b *IPAMBlock) IPToOrdinal(ip cnet.IP) (int, error) {
|
||||
netIP, _, _ := cnet.ParseCIDR(b.Spec.CIDR)
|
||||
ipAsInt := cnet.IPToBigInt(ip)
|
||||
baseInt := cnet.IPToBigInt(*netIP)
|
||||
ord := big.NewInt(0).Sub(ipAsInt, baseInt).Int64()
|
||||
if ord < 0 || ord >= int64(b.NumAddresses()) {
|
||||
return 0, fmt.Errorf("IP %s not in block %d-%s", ip, b.Spec.ID, b.Spec.CIDR)
|
||||
}
|
||||
return int(ord), nil
|
||||
}
|
||||
|
||||
func (b *IPAMBlock) NumFreeAddresses() int {
|
||||
return len(b.Spec.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 *IPAMBlock) Empty() bool {
|
||||
return b.containsOnlyReservedIPs()
|
||||
}
|
||||
|
||||
func (b *IPAMBlock) MarkDeleted() {
|
||||
b.Spec.Deleted = true
|
||||
}
|
||||
|
||||
func (b *IPAMBlock) IsDeleted() bool {
|
||||
return b.Spec.Deleted
|
||||
}
|
||||
|
||||
// containsOnlyReservedIPs returns true if the block is empty excepted for
|
||||
// expected "reserved" IP addresses.
|
||||
func (b *IPAMBlock) containsOnlyReservedIPs() bool {
|
||||
for _, attrIdx := range b.Spec.Allocations {
|
||||
if attrIdx == nil {
|
||||
continue
|
||||
}
|
||||
attrs := b.Spec.Attributes[*attrIdx]
|
||||
if strings.ToLower(attrs.AttrPrimary) != ReservedHandle {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *IPAMBlock) NumReservedAddresses() int {
|
||||
sum := 0
|
||||
for _, attrIdx := range b.Spec.Allocations {
|
||||
if attrIdx == nil {
|
||||
continue
|
||||
}
|
||||
attrs := b.Spec.Attributes[*attrIdx]
|
||||
if strings.ToLower(attrs.AttrPrimary) == ReservedHandle {
|
||||
sum += 1
|
||||
}
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
func (b IPAMBlock) attributeIndexesByHandle(handleID string) []int {
|
||||
indexes := []int{}
|
||||
for i, attr := range b.Spec.Attributes {
|
||||
if attr.AttrPrimary == handleID {
|
||||
indexes = append(indexes, i)
|
||||
}
|
||||
}
|
||||
return indexes
|
||||
}
|
||||
|
||||
func (b *IPAMBlock) deleteAttributes(delIndexes, ordinals []int) {
|
||||
newIndexes := make([]*int, len(b.Spec.Attributes))
|
||||
newAttrs := []AllocationAttribute{}
|
||||
y := 0 // Next free slot in the new attributes list.
|
||||
for x := range b.Spec.Attributes {
|
||||
if !intInSlice(x, delIndexes) {
|
||||
// Attribute at x is not being deleted. Build a mapping
|
||||
// of old attribute index (x) to new attribute index (y).
|
||||
newIndex := y
|
||||
newIndexes[x] = &newIndex
|
||||
y += 1
|
||||
newAttrs = append(newAttrs, b.Spec.Attributes[x])
|
||||
}
|
||||
}
|
||||
b.Spec.Attributes = newAttrs
|
||||
|
||||
// Update attribute indexes for all allocations in this block.
|
||||
for i := 0; i < b.NumAddresses(); i++ {
|
||||
if b.Spec.Allocations[i] != nil {
|
||||
// Get the new index that corresponds to the old index
|
||||
// and update the allocation.
|
||||
newIndex := newIndexes[*b.Spec.Allocations[i]]
|
||||
b.Spec.Allocations[i] = newIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (b *IPAMBlock) ReleaseByHandle(handleID string) int {
|
||||
attrIndexes := b.attributeIndexesByHandle(handleID)
|
||||
if len(attrIndexes) == 0 {
|
||||
// Nothing to release.
|
||||
return 0
|
||||
}
|
||||
|
||||
// There are addresses to release.
|
||||
ordinals := []int{}
|
||||
var o int
|
||||
for o = 0; o < b.NumAddresses(); o++ {
|
||||
// Only check allocated ordinals.
|
||||
if b.Spec.Allocations[o] != nil && intInSlice(*b.Spec.Allocations[o], attrIndexes) {
|
||||
// Release this ordinal.
|
||||
ordinals = append(ordinals, o)
|
||||
}
|
||||
}
|
||||
|
||||
// Clean and reorder attributes.
|
||||
b.deleteAttributes(attrIndexes, ordinals)
|
||||
|
||||
// Release the addresses.
|
||||
for _, o := range ordinals {
|
||||
b.Spec.Allocations[o] = nil
|
||||
b.Spec.Unallocated = append(b.Spec.Unallocated, o)
|
||||
}
|
||||
return len(ordinals)
|
||||
}
|
||||
|
||||
func (b *IPAMBlock) findOrAddAttribute(handleID string, attrs map[string]string) int {
|
||||
attr := AllocationAttribute{handleID, attrs}
|
||||
for idx, existing := range b.Spec.Attributes {
|
||||
if reflect.DeepEqual(attr, existing) {
|
||||
return idx
|
||||
}
|
||||
}
|
||||
|
||||
// Does not exist - add it.
|
||||
attrIndex := len(b.Spec.Attributes)
|
||||
b.Spec.Attributes = append(b.Spec.Attributes, attr)
|
||||
return attrIndex
|
||||
}
|
||||
|
||||
func intInSlice(searchInt int, slice []int) bool {
|
||||
for _, v := range slice {
|
||||
if v == searchInt {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
//This just initializes the data structure and does not call the api to create
|
||||
func NewBlock(pool *IPPool, cidr cnet.IPNet, rsvdAttr *ReservedAttr) *IPAMBlock {
|
||||
b := IPAMBlock{}
|
||||
|
||||
b.Labels = map[string]string{
|
||||
IPPoolNameLabel: pool.Name,
|
||||
}
|
||||
b.Spec.CIDR = cidr.String()
|
||||
b.Spec.ID = pool.ID()
|
||||
b.Name = b.BlockName()
|
||||
|
||||
numAddresses := b.NumAddresses()
|
||||
b.Spec.Allocations = make([]*int, numAddresses)
|
||||
b.Spec.Unallocated = make([]int, numAddresses)
|
||||
|
||||
// Initialize unallocated ordinals.
|
||||
for i := 0; i < numAddresses; i++ {
|
||||
b.Spec.Unallocated[i] = i
|
||||
}
|
||||
|
||||
if rsvdAttr != nil {
|
||||
// Reserve IPs based on host reserved attributes.
|
||||
// For example, with windows OS, the following IP addresses of the block are
|
||||
// reserved. This is done by pre-allocating them during initialization
|
||||
// time only.
|
||||
// IPs : x.0, x.1, x.2 and x.bcastAddr (e.g. x.255 for /24 subnet)
|
||||
|
||||
// nil attributes
|
||||
attrs := make(map[string]string)
|
||||
attrs["note"] = rsvdAttr.Note
|
||||
handleID := rsvdAttr.Handle
|
||||
b.Spec.Unallocated = b.Spec.Unallocated[rsvdAttr.StartOfBlock : numAddresses-rsvdAttr.EndOfBlock]
|
||||
attrIndex := len(b.Spec.Attributes)
|
||||
for i := 0; i < rsvdAttr.StartOfBlock; i++ {
|
||||
b.Spec.Allocations[i] = &attrIndex
|
||||
}
|
||||
for i := 1; i <= rsvdAttr.EndOfBlock; i++ {
|
||||
b.Spec.Allocations[numAddresses-i] = &attrIndex
|
||||
}
|
||||
|
||||
// Create slice of IPs and perform the allocations.
|
||||
attr := AllocationAttribute{
|
||||
AttrPrimary: handleID,
|
||||
AttrSecondary: attrs,
|
||||
}
|
||||
b.Spec.Attributes = append(b.Spec.Attributes, attr)
|
||||
}
|
||||
|
||||
return &b
|
||||
}
|
||||
|
||||
type ReservedAttr struct {
|
||||
// Number of addresses reserved from start of the block.
|
||||
StartOfBlock int
|
||||
|
||||
// Number of addresses reserved from end of the block.
|
||||
EndOfBlock int
|
||||
|
||||
// Handle for reserved addresses.
|
||||
Handle string
|
||||
|
||||
// A description about the reserves.
|
||||
Note string
|
||||
}
|
||||
110
vendor/kubesphere.io/api/network/v1alpha1/ipamhandle_types.go
generated
vendored
Normal file
110
vendor/kubesphere.io/api/network/v1alpha1/ipamhandle_types.go
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
Copyright 2020 The KubeSphere authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/projectcalico/libcalico-go/lib/names"
|
||||
cnet "github.com/projectcalico/libcalico-go/lib/net"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
ResourceKindIPAMHandle = "IPAMHandle"
|
||||
ResourceSingularIPAMHandle = "ipamhandle"
|
||||
ResourcePluralIPAMHandle = "ipamhandles"
|
||||
)
|
||||
|
||||
// +genclient
|
||||
// +genclient:nonNamespaced
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +k8s:openapi-gen=true
|
||||
// +kubebuilder:resource:scope=Cluster
|
||||
type IPAMHandle struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
// Specification of the IPAMHandle.
|
||||
Spec IPAMHandleSpec `json:"spec,omitempty"`
|
||||
}
|
||||
|
||||
// IPAMHandleSpec contains the specification for an IPAMHandle resource.
|
||||
type IPAMHandleSpec struct {
|
||||
HandleID string `json:"handleID"`
|
||||
Block map[string]int `json:"block"`
|
||||
Deleted bool `json:"deleted"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +genclient:nonNamespaced
|
||||
type IPAMHandleList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata"`
|
||||
Items []IPAMHandle `json:"items"`
|
||||
}
|
||||
|
||||
func (h *IPAMHandle) IncrementBlock(block *IPAMBlock, num int) int {
|
||||
newNum := num
|
||||
if val, ok := h.Spec.Block[block.String()]; ok {
|
||||
// An entry exists for this block, increment the number
|
||||
// of allocations.
|
||||
newNum = val + num
|
||||
}
|
||||
h.Spec.Block[block.String()] = newNum
|
||||
return newNum
|
||||
}
|
||||
|
||||
func (h *IPAMHandle) Empty() bool {
|
||||
return len(h.Spec.Block) == 0
|
||||
}
|
||||
|
||||
func (h *IPAMHandle) MarkDeleted() {
|
||||
h.Spec.Deleted = true
|
||||
}
|
||||
|
||||
func (h *IPAMHandle) IsDeleted() bool {
|
||||
return h.Spec.Deleted
|
||||
}
|
||||
|
||||
func (h *IPAMHandle) DecrementBlock(block *IPAMBlock, num int) (*int, error) {
|
||||
if current, ok := h.Spec.Block[block.String()]; !ok {
|
||||
// This entry doesn't exist.
|
||||
return nil, fmt.Errorf("Tried to decrement block %s by %v but it isn't linked to handle %s", block.BlockName(), num, h.Spec.HandleID)
|
||||
} else {
|
||||
newNum := current - num
|
||||
if newNum < 0 {
|
||||
return nil, fmt.Errorf("Tried to decrement block %s by %v but it only has %v addresses on handle %s", block.BlockName(), num, current, h.Spec.HandleID)
|
||||
}
|
||||
|
||||
if newNum == 0 {
|
||||
delete(h.Spec.Block, block.String())
|
||||
} else {
|
||||
h.Spec.Block[block.String()] = newNum
|
||||
}
|
||||
return &newNum, nil
|
||||
}
|
||||
}
|
||||
|
||||
func ConvertToBlockName(k string) string {
|
||||
strs := strings.SplitN(k, "-", 2)
|
||||
id, _ := strconv.Atoi(strs[0])
|
||||
_, blockCIDR, _ := cnet.ParseCIDR(strs[1])
|
||||
|
||||
return fmt.Sprintf("%d-%s", id, names.CIDRToName(*blockCIDR))
|
||||
}
|
||||
230
vendor/kubesphere.io/api/network/v1alpha1/ippool_types.go
generated
vendored
Normal file
230
vendor/kubesphere.io/api/network/v1alpha1/ippool_types.go
generated
vendored
Normal file
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
Copyright 2020 The KubeSphere authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
cnet "github.com/projectcalico/libcalico-go/lib/net"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
ResourceKindIPPool = "IPPool"
|
||||
ResourceSingularIPPool = "ippool"
|
||||
ResourcePluralIPPool = "ippools"
|
||||
|
||||
// scope type > id > name
|
||||
// id used to detect cidr overlap
|
||||
IPPoolTypeLabel = "ippool.network.kubesphere.io/type"
|
||||
IPPoolNameLabel = "ippool.network.kubesphere.io/name"
|
||||
IPPoolIDLabel = "ippool.network.kubesphere.io/id"
|
||||
IPPoolDefaultLabel = "ippool.network.kubesphere.io/default"
|
||||
|
||||
IPPoolTypeNone = "none"
|
||||
IPPoolTypeLocal = "local"
|
||||
IPPoolTypeCalico = "calico"
|
||||
)
|
||||
|
||||
// +genclient
|
||||
// +genclient:nonNamespaced
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +k8s:openapi-gen=true
|
||||
// +kubebuilder:subresource:status
|
||||
// +kubebuilder:resource:scope=Cluster
|
||||
type IPPool struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
// +optional
|
||||
Spec IPPoolSpec `json:"spec,omitempty"`
|
||||
// +optional
|
||||
Status IPPoolStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type VLANConfig struct {
|
||||
VlanId uint32 `json:"vlanId"`
|
||||
Master string `json:"master"`
|
||||
}
|
||||
|
||||
type Route struct {
|
||||
Dst string `json:"dst,omitempty"`
|
||||
GW string `json:"gateway,omitempty"`
|
||||
}
|
||||
|
||||
// DNS contains values interesting for DNS resolvers
|
||||
type DNS struct {
|
||||
Nameservers []string `json:"nameservers,omitempty"`
|
||||
Domain string `json:"domain,omitempty"`
|
||||
Search []string `json:"search,omitempty"`
|
||||
Options []string `json:"options,omitempty"`
|
||||
}
|
||||
|
||||
type WorkspaceStatus struct {
|
||||
Allocations int `json:"allocations"`
|
||||
}
|
||||
|
||||
type IPPoolStatus struct {
|
||||
Unallocated int `json:"unallocated"`
|
||||
Allocations int `json:"allocations"`
|
||||
Capacity int `json:"capacity"`
|
||||
Reserved int `json:"reserved,omitempty"`
|
||||
Synced bool `json:"synced,omitempty"`
|
||||
Workspaces map[string]WorkspaceStatus `json:"workspaces,omitempty"`
|
||||
}
|
||||
|
||||
type IPPoolSpec struct {
|
||||
Type string `json:"type"`
|
||||
|
||||
// The pool CIDR.
|
||||
CIDR string `json:"cidr"`
|
||||
|
||||
// The first ip, inclusive
|
||||
RangeStart string `json:"rangeStart,omitempty"`
|
||||
|
||||
// The last ip, inclusive
|
||||
RangeEnd string `json:"rangeEnd,omitempty"`
|
||||
|
||||
// When disabled is true, IPAM will not assign addresses from this pool.
|
||||
Disabled bool `json:"disabled,omitempty"`
|
||||
|
||||
// The block size to use for IP address assignments from this pool. Defaults to 26 for IPv4 and 112 for IPv6.
|
||||
BlockSize int `json:"blockSize,omitempty"`
|
||||
|
||||
VLAN VLANConfig `json:"vlanConfig,omitempty"`
|
||||
|
||||
Gateway string `json:"gateway,omitempty"`
|
||||
Routes []Route `json:"routes,omitempty"`
|
||||
DNS DNS `json:"dns,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
// +genclient:nonNamespaced
|
||||
type IPPoolList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []IPPool `json:"items"`
|
||||
}
|
||||
|
||||
const (
|
||||
VLAN = "vlan"
|
||||
Calico = "calico"
|
||||
Porter = "porter"
|
||||
Pod = "pod"
|
||||
VLANIDStart = 1
|
||||
VLANIDEnd = 4097
|
||||
PorterID = 4098
|
||||
CalicoID = 4099
|
||||
PodID = 0
|
||||
)
|
||||
|
||||
// Find the ordinal (i.e. how far into the block) a given IP lies. Returns an error if the IP is outside the block.
|
||||
func (b IPPool) IPToOrdinal(ip cnet.IP) (int, error) {
|
||||
_, cidr, _ := cnet.ParseCIDR(b.Spec.CIDR)
|
||||
ipAsInt := cnet.IPToBigInt(ip)
|
||||
baseInt := cnet.IPToBigInt(cnet.IP{IP: cidr.IP})
|
||||
ord := big.NewInt(0).Sub(ipAsInt, baseInt).Int64()
|
||||
if ord < 0 || ord >= int64(b.NumAddresses()) {
|
||||
return 0, fmt.Errorf("IP %s not in pool %s", ip, b.Spec.CIDR)
|
||||
}
|
||||
return int(ord), nil
|
||||
}
|
||||
|
||||
// Get number of addresses covered by the block
|
||||
func (b IPPool) NumAddresses() int {
|
||||
_, cidr, _ := cnet.ParseCIDR(b.Spec.CIDR)
|
||||
ones, size := cidr.Mask.Size()
|
||||
numAddresses := 1 << uint(size-ones)
|
||||
return numAddresses
|
||||
}
|
||||
|
||||
func (b IPPool) Type() string {
|
||||
if b.Spec.Type == VLAN {
|
||||
return IPPoolTypeLocal
|
||||
}
|
||||
|
||||
return b.Spec.Type
|
||||
}
|
||||
|
||||
func (b IPPool) NumReservedAddresses() int {
|
||||
return b.StartReservedAddressed() + b.EndReservedAddressed()
|
||||
}
|
||||
|
||||
func (b IPPool) StartReservedAddressed() int {
|
||||
if b.Spec.RangeStart == "" {
|
||||
return 0
|
||||
}
|
||||
start, _ := b.IPToOrdinal(*cnet.ParseIP(b.Spec.RangeStart))
|
||||
return start
|
||||
}
|
||||
|
||||
func (b IPPool) EndReservedAddressed() int {
|
||||
if b.Spec.RangeEnd == "" {
|
||||
return 0
|
||||
}
|
||||
total := b.NumAddresses()
|
||||
end, _ := b.IPToOrdinal(*cnet.ParseIP(b.Spec.RangeEnd))
|
||||
return total - end - 1
|
||||
}
|
||||
|
||||
func (b IPPool) Overlapped(dst IPPool) bool {
|
||||
if b.ID() != dst.ID() {
|
||||
return false
|
||||
}
|
||||
|
||||
_, cidr, _ := cnet.ParseCIDR(b.Spec.CIDR)
|
||||
_, cidrDst, _ := cnet.ParseCIDR(dst.Spec.CIDR)
|
||||
|
||||
return cidr.IsNetOverlap(cidrDst.IPNet)
|
||||
}
|
||||
|
||||
func (pool IPPool) ID() uint32 {
|
||||
switch pool.Spec.Type {
|
||||
case VLAN:
|
||||
return pool.Spec.VLAN.VlanId + VLANIDStart
|
||||
case Porter:
|
||||
return PorterID
|
||||
case Calico:
|
||||
return CalicoID
|
||||
}
|
||||
|
||||
return PodID
|
||||
}
|
||||
|
||||
func (p IPPool) TypeInvalid() bool {
|
||||
typeStr := p.Spec.Type
|
||||
if typeStr == VLAN || typeStr == Porter || typeStr == Pod {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (p IPPool) Disabled() bool {
|
||||
return p.Spec.Disabled
|
||||
}
|
||||
|
||||
func (p IPPool) V4() bool {
|
||||
ip, _, _ := cnet.ParseCIDR(p.Spec.CIDR)
|
||||
if ip.To4() != nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const IPPoolFinalizer = "finalizers.network.kubesphere.io/ippool"
|
||||
154
vendor/kubesphere.io/api/network/v1alpha1/namespacenetworkpolicy_types.go
generated
vendored
Normal file
154
vendor/kubesphere.io/api/network/v1alpha1/namespacenetworkpolicy_types.go
generated
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
Copyright 2019 The KubeSphere authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
k8snet "k8s.io/api/networking/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
ResourceKindNamespaceNetworkPolicy = "NamespaceNetworkPolicy"
|
||||
ResourceSingularNamespaceNetworkPolicy = "namespacenetworkpolicy"
|
||||
ResourcePluralNamespaceNetworkPolicy = "namespacenetworkpolicies"
|
||||
)
|
||||
|
||||
// NamespaceNetworkPolicySpec provides the specification of a NamespaceNetworkPolicy
|
||||
type NamespaceNetworkPolicySpec struct {
|
||||
// List of ingress rules to be applied to the selected pods. Traffic is allowed to
|
||||
// a pod if there are no NetworkPolicies selecting the pod
|
||||
// (and cluster policy otherwise allows the traffic), OR if the traffic source is
|
||||
// the pod's local node, OR if the traffic matches at least one ingress rule
|
||||
// across all of the NetworkPolicy objects whose podSelector matches the pod. If
|
||||
// this field is empty then this NetworkPolicy does not allow any traffic (and serves
|
||||
// solely to ensure that the pods it selects are isolated by default)
|
||||
// +optional
|
||||
Ingress []NetworkPolicyIngressRule `json:"ingress,omitempty" protobuf:"bytes,1,rep,name=ingress"`
|
||||
|
||||
// List of egress rules to be applied to the selected pods. Outgoing traffic is
|
||||
// allowed if there are no NetworkPolicies selecting the pod (and cluster policy
|
||||
// otherwise allows the traffic), OR if the traffic matches at least one egress rule
|
||||
// across all of the NetworkPolicy objects whose podSelector matches the pod. If
|
||||
// this field is empty then this NetworkPolicy limits all outgoing traffic (and serves
|
||||
// solely to ensure that the pods it selects are isolated by default).
|
||||
// This field is beta-level in 1.8
|
||||
// +optional
|
||||
Egress []NetworkPolicyEgressRule `json:"egress,omitempty" protobuf:"bytes,2,rep,name=egress"`
|
||||
|
||||
// List of rule types that the NetworkPolicy relates to.
|
||||
// Valid options are "Ingress", "Egress", or "Ingress,Egress".
|
||||
// If this field is not specified, it will default based on the existence of Ingress or Egress rules;
|
||||
// policies that contain an Egress section are assumed to affect Egress, and all policies
|
||||
// (whether or not they contain an Ingress section) are assumed to affect Ingress.
|
||||
// If you want to write an egress-only policy, you must explicitly specify policyTypes [ "Egress" ].
|
||||
// Likewise, if you want to write a policy that specifies that no egress is allowed,
|
||||
// you must specify a policyTypes value that include "Egress" (since such a policy would not include
|
||||
// an Egress section and would otherwise default to just [ "Ingress" ]).
|
||||
// This field is beta-level in 1.8
|
||||
// +optional
|
||||
PolicyTypes []k8snet.PolicyType `json:"policyTypes,omitempty" protobuf:"bytes,3,rep,name=policyTypes,casttype=PolicyType"`
|
||||
}
|
||||
|
||||
// NetworkPolicyIngressRule describes a particular set of traffic that is allowed to the pods
|
||||
// matched by a NetworkPolicySpec's podSelector. The traffic must match both ports and from.
|
||||
type NetworkPolicyIngressRule struct {
|
||||
// List of ports which should be made accessible on the pods selected for this
|
||||
// rule. Each item in this list is combined using a logical OR. If this field is
|
||||
// empty or missing, this rule matches all ports (traffic not restricted by port).
|
||||
// If this field is present and contains at least one item, then this rule allows
|
||||
// traffic only if the traffic matches at least one port in the list.
|
||||
// +optional
|
||||
Ports []k8snet.NetworkPolicyPort `json:"ports,omitempty" protobuf:"bytes,1,rep,name=ports"`
|
||||
|
||||
// List of sources which should be able to access the pods selected for this rule.
|
||||
// Items in this list are combined using a logical OR operation. If this field is
|
||||
// empty or missing, this rule matches all sources (traffic not restricted by
|
||||
// source). If this field is present and contains at least one item, this rule
|
||||
// allows traffic only if the traffic matches at least one item in the from list.
|
||||
// +optional
|
||||
From []NetworkPolicyPeer `json:"from,omitempty" protobuf:"bytes,2,rep,name=from"`
|
||||
}
|
||||
|
||||
// NetworkPolicyEgressRule describes a particular set of traffic that is allowed out of pods
|
||||
// matched by a NetworkPolicySpec's podSelector. The traffic must match both ports and to.
|
||||
// This type is beta-level in 1.8
|
||||
type NetworkPolicyEgressRule struct {
|
||||
// List of destination ports for outgoing traffic.
|
||||
// Each item in this list is combined using a logical OR. If this field is
|
||||
// empty or missing, this rule matches all ports (traffic not restricted by port).
|
||||
// If this field is present and contains at least one item, then this rule allows
|
||||
// traffic only if the traffic matches at least one port in the list.
|
||||
// +optional
|
||||
Ports []k8snet.NetworkPolicyPort `json:"ports,omitempty" protobuf:"bytes,1,rep,name=ports"`
|
||||
|
||||
// List of destinations for outgoing traffic of pods selected for this rule.
|
||||
// Items in this list are combined using a logical OR operation. If this field is
|
||||
// empty or missing, this rule matches all destinations (traffic not restricted by
|
||||
// destination). If this field is present and contains at least one item, this rule
|
||||
// allows traffic only if the traffic matches at least one item in the to list.
|
||||
// +optional
|
||||
To []NetworkPolicyPeer `json:"to,omitempty" protobuf:"bytes,2,rep,name=to"`
|
||||
}
|
||||
|
||||
type NamespaceSelector struct {
|
||||
Name string `json:"name" protobuf:"bytes,1,name=name"`
|
||||
}
|
||||
|
||||
type ServiceSelector struct {
|
||||
Name string `json:"name" protobuf:"bytes,1,name=name"`
|
||||
Namespace string `json:"namespace" protobuf:"bytes,2,name=namespace"`
|
||||
}
|
||||
|
||||
// NetworkPolicyPeer describes a peer to allow traffic from. Only certain combinations of
|
||||
// fields are allowed
|
||||
type NetworkPolicyPeer struct {
|
||||
// +optional
|
||||
NamespaceSelector *NamespaceSelector `json:"namespace,omitempty" protobuf:"bytes,1,opt,name=namespace"`
|
||||
|
||||
// IPBlock defines policy on a particular IPBlock. If this field is set then
|
||||
// neither of the other fields can be.
|
||||
// +optional
|
||||
IPBlock *k8snet.IPBlock `json:"ipBlock,omitempty" protobuf:"bytes,2,rep,name=ipBlock"`
|
||||
|
||||
ServiceSelector *ServiceSelector `json:"service,omitempty" protobuf:"bytes,3,opt,name=service"`
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// NamespaceNetworkPolicy is the Schema for the namespacenetworkpolicies API
|
||||
// +k8s:openapi-gen=true
|
||||
// +kubebuilder:resource:categories="networking",shortName="nsnp"
|
||||
type NamespaceNetworkPolicy struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec NamespaceNetworkPolicySpec `json:"spec,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// NamespaceNetworkPolicyList contains a list of NamespaceNetworkPolicy
|
||||
type NamespaceNetworkPolicyList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []NamespaceNetworkPolicy `json:"items"`
|
||||
}
|
||||
|
||||
const (
|
||||
NSNPPrefix = "nsnp-"
|
||||
)
|
||||
4408
vendor/kubesphere.io/api/network/v1alpha1/openapi_generated.go
generated
vendored
Normal file
4408
vendor/kubesphere.io/api/network/v1alpha1/openapi_generated.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
53
vendor/kubesphere.io/api/network/v1alpha1/register.go
generated
vendored
Normal file
53
vendor/kubesphere.io/api/network/v1alpha1/register.go
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
Copyright 2020 The KubeSphere authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// NOTE: Boilerplate only. Ignore this file.
|
||||
|
||||
// Package v1alpha1 contains API Schema definitions for the network v1alpha1 API group
|
||||
// +k8s:openapi-gen=true
|
||||
// +k8s:deepcopy-gen=package,register
|
||||
// +k8s:conversion-gen=kubesphere.io/api/network
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +groupName=network.kubesphere.io
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/scheme"
|
||||
)
|
||||
|
||||
var (
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
SchemeGroupVersion = schema.GroupVersion{Group: "network.kubesphere.io", Version: "v1alpha1"}
|
||||
|
||||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
|
||||
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
|
||||
|
||||
// AddToScheme is required by pkg/client/...
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&IPAMHandle{}, &IPAMHandleList{})
|
||||
SchemeBuilder.Register(&IPAMBlock{}, &IPAMBlockList{})
|
||||
SchemeBuilder.Register(&IPPool{}, &IPPoolList{})
|
||||
SchemeBuilder.Register(&NamespaceNetworkPolicy{}, &NamespaceNetworkPolicyList{})
|
||||
}
|
||||
|
||||
// Resource is required by pkg/client/listers/...
|
||||
func Resource(resource string) schema.GroupResource {
|
||||
return SchemeGroupVersion.WithResource(resource).GroupResource()
|
||||
}
|
||||
651
vendor/kubesphere.io/api/network/v1alpha1/zz_generated.deepcopy.go
generated
vendored
Normal file
651
vendor/kubesphere.io/api/network/v1alpha1/zz_generated.deepcopy.go
generated
vendored
Normal file
@@ -0,0 +1,651 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2020 The KubeSphere Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by deepcopy-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1 "k8s.io/api/networking/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *AllocationAttribute) DeepCopyInto(out *AllocationAttribute) {
|
||||
*out = *in
|
||||
if in.AttrSecondary != nil {
|
||||
in, out := &in.AttrSecondary, &out.AttrSecondary
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AllocationAttribute.
|
||||
func (in *AllocationAttribute) DeepCopy() *AllocationAttribute {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(AllocationAttribute)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DNS) DeepCopyInto(out *DNS) {
|
||||
*out = *in
|
||||
if in.Nameservers != nil {
|
||||
in, out := &in.Nameservers, &out.Nameservers
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Search != nil {
|
||||
in, out := &in.Search, &out.Search
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Options != nil {
|
||||
in, out := &in.Options, &out.Options
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNS.
|
||||
func (in *DNS) DeepCopy() *DNS {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DNS)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *IPAMBlock) DeepCopyInto(out *IPAMBlock) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAMBlock.
|
||||
func (in *IPAMBlock) DeepCopy() *IPAMBlock {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(IPAMBlock)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *IPAMBlock) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *IPAMBlockList) DeepCopyInto(out *IPAMBlockList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]IPAMBlock, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAMBlockList.
|
||||
func (in *IPAMBlockList) DeepCopy() *IPAMBlockList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(IPAMBlockList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *IPAMBlockList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *IPAMBlockSpec) DeepCopyInto(out *IPAMBlockSpec) {
|
||||
*out = *in
|
||||
if in.Allocations != nil {
|
||||
in, out := &in.Allocations, &out.Allocations
|
||||
*out = make([]*int, len(*in))
|
||||
for i := range *in {
|
||||
if (*in)[i] != nil {
|
||||
in, out := &(*in)[i], &(*out)[i]
|
||||
*out = new(int)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
}
|
||||
if in.Unallocated != nil {
|
||||
in, out := &in.Unallocated, &out.Unallocated
|
||||
*out = make([]int, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Attributes != nil {
|
||||
in, out := &in.Attributes, &out.Attributes
|
||||
*out = make([]AllocationAttribute, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAMBlockSpec.
|
||||
func (in *IPAMBlockSpec) DeepCopy() *IPAMBlockSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(IPAMBlockSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *IPAMHandle) DeepCopyInto(out *IPAMHandle) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAMHandle.
|
||||
func (in *IPAMHandle) DeepCopy() *IPAMHandle {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(IPAMHandle)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *IPAMHandle) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *IPAMHandleList) DeepCopyInto(out *IPAMHandleList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]IPAMHandle, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAMHandleList.
|
||||
func (in *IPAMHandleList) DeepCopy() *IPAMHandleList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(IPAMHandleList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *IPAMHandleList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *IPAMHandleSpec) DeepCopyInto(out *IPAMHandleSpec) {
|
||||
*out = *in
|
||||
if in.Block != nil {
|
||||
in, out := &in.Block, &out.Block
|
||||
*out = make(map[string]int, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAMHandleSpec.
|
||||
func (in *IPAMHandleSpec) DeepCopy() *IPAMHandleSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(IPAMHandleSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *IPPool) DeepCopyInto(out *IPPool) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
in.Status.DeepCopyInto(&out.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPool.
|
||||
func (in *IPPool) DeepCopy() *IPPool {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(IPPool)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *IPPool) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *IPPoolList) DeepCopyInto(out *IPPoolList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]IPPool, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPoolList.
|
||||
func (in *IPPoolList) DeepCopy() *IPPoolList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(IPPoolList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *IPPoolList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *IPPoolSpec) DeepCopyInto(out *IPPoolSpec) {
|
||||
*out = *in
|
||||
out.VLAN = in.VLAN
|
||||
if in.Routes != nil {
|
||||
in, out := &in.Routes, &out.Routes
|
||||
*out = make([]Route, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
in.DNS.DeepCopyInto(&out.DNS)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPoolSpec.
|
||||
func (in *IPPoolSpec) DeepCopy() *IPPoolSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(IPPoolSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *IPPoolStatus) DeepCopyInto(out *IPPoolStatus) {
|
||||
*out = *in
|
||||
if in.Workspaces != nil {
|
||||
in, out := &in.Workspaces, &out.Workspaces
|
||||
*out = make(map[string]WorkspaceStatus, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPoolStatus.
|
||||
func (in *IPPoolStatus) DeepCopy() *IPPoolStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(IPPoolStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NamespaceNetworkPolicy) DeepCopyInto(out *NamespaceNetworkPolicy) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NamespaceNetworkPolicy.
|
||||
func (in *NamespaceNetworkPolicy) DeepCopy() *NamespaceNetworkPolicy {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(NamespaceNetworkPolicy)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *NamespaceNetworkPolicy) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NamespaceNetworkPolicyList) DeepCopyInto(out *NamespaceNetworkPolicyList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]NamespaceNetworkPolicy, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NamespaceNetworkPolicyList.
|
||||
func (in *NamespaceNetworkPolicyList) DeepCopy() *NamespaceNetworkPolicyList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(NamespaceNetworkPolicyList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *NamespaceNetworkPolicyList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NamespaceNetworkPolicySpec) DeepCopyInto(out *NamespaceNetworkPolicySpec) {
|
||||
*out = *in
|
||||
if in.Ingress != nil {
|
||||
in, out := &in.Ingress, &out.Ingress
|
||||
*out = make([]NetworkPolicyIngressRule, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.Egress != nil {
|
||||
in, out := &in.Egress, &out.Egress
|
||||
*out = make([]NetworkPolicyEgressRule, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.PolicyTypes != nil {
|
||||
in, out := &in.PolicyTypes, &out.PolicyTypes
|
||||
*out = make([]v1.PolicyType, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NamespaceNetworkPolicySpec.
|
||||
func (in *NamespaceNetworkPolicySpec) DeepCopy() *NamespaceNetworkPolicySpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(NamespaceNetworkPolicySpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NamespaceSelector) DeepCopyInto(out *NamespaceSelector) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NamespaceSelector.
|
||||
func (in *NamespaceSelector) DeepCopy() *NamespaceSelector {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(NamespaceSelector)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NetworkPolicyEgressRule) DeepCopyInto(out *NetworkPolicyEgressRule) {
|
||||
*out = *in
|
||||
if in.Ports != nil {
|
||||
in, out := &in.Ports, &out.Ports
|
||||
*out = make([]v1.NetworkPolicyPort, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.To != nil {
|
||||
in, out := &in.To, &out.To
|
||||
*out = make([]NetworkPolicyPeer, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkPolicyEgressRule.
|
||||
func (in *NetworkPolicyEgressRule) DeepCopy() *NetworkPolicyEgressRule {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(NetworkPolicyEgressRule)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NetworkPolicyIngressRule) DeepCopyInto(out *NetworkPolicyIngressRule) {
|
||||
*out = *in
|
||||
if in.Ports != nil {
|
||||
in, out := &in.Ports, &out.Ports
|
||||
*out = make([]v1.NetworkPolicyPort, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
if in.From != nil {
|
||||
in, out := &in.From, &out.From
|
||||
*out = make([]NetworkPolicyPeer, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkPolicyIngressRule.
|
||||
func (in *NetworkPolicyIngressRule) DeepCopy() *NetworkPolicyIngressRule {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(NetworkPolicyIngressRule)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NetworkPolicyPeer) DeepCopyInto(out *NetworkPolicyPeer) {
|
||||
*out = *in
|
||||
if in.NamespaceSelector != nil {
|
||||
in, out := &in.NamespaceSelector, &out.NamespaceSelector
|
||||
*out = new(NamespaceSelector)
|
||||
**out = **in
|
||||
}
|
||||
if in.IPBlock != nil {
|
||||
in, out := &in.IPBlock, &out.IPBlock
|
||||
*out = new(v1.IPBlock)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.ServiceSelector != nil {
|
||||
in, out := &in.ServiceSelector, &out.ServiceSelector
|
||||
*out = new(ServiceSelector)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkPolicyPeer.
|
||||
func (in *NetworkPolicyPeer) DeepCopy() *NetworkPolicyPeer {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(NetworkPolicyPeer)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ReservedAttr) DeepCopyInto(out *ReservedAttr) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReservedAttr.
|
||||
func (in *ReservedAttr) DeepCopy() *ReservedAttr {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ReservedAttr)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Route) DeepCopyInto(out *Route) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Route.
|
||||
func (in *Route) DeepCopy() *Route {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(Route)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ServiceSelector) DeepCopyInto(out *ServiceSelector) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceSelector.
|
||||
func (in *ServiceSelector) DeepCopy() *ServiceSelector {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ServiceSelector)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *VLANConfig) DeepCopyInto(out *VLANConfig) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VLANConfig.
|
||||
func (in *VLANConfig) DeepCopy() *VLANConfig {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(VLANConfig)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *WorkspaceStatus) DeepCopyInto(out *WorkspaceStatus) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WorkspaceStatus.
|
||||
func (in *WorkspaceStatus) DeepCopy() *WorkspaceStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(WorkspaceStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
Reference in New Issue
Block a user