github.com/tigera/api@v0.0.0-20240320170621-278e89a8c5fb/pkg/apis/projectcalico/v3/ipamconfig.go (about) 1 // Copyright (c) 2022 Tigera, Inc. All rights reserved. 2 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package v3 16 17 import ( 18 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 19 ) 20 21 const ( 22 KindIPAMConfiguration = "IPAMConfiguration" 23 KindIPAMConfigurationList = "IPAMConfigurationList" 24 ) 25 26 // +genclient:nonNamespaced 27 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 28 29 // IPAMConfigurationList contains a list of IPAMConfiguration resources. 30 type IPAMConfigurationList struct { 31 metav1.TypeMeta `json:",inline"` 32 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 33 34 Items []IPAMConfiguration `json:"items" protobuf:"bytes,2,rep,name=items"` 35 } 36 37 // +genclient 38 // +genclient:nonNamespaced 39 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 40 41 // IPAMConfiguration contains information about a block for IP address assignment. 42 type IPAMConfiguration struct { 43 metav1.TypeMeta `json:",inline"` 44 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 45 46 Spec IPAMConfigurationSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` 47 } 48 49 // IPAMConfigurationSpec contains the specification for an IPPool resource. 50 type IPAMConfigurationSpec struct { 51 // When StrictAffinity is true, borrowing IP addresses is not allowed. 52 StrictAffinity bool `json:"strictAffinity" validate:"required"` 53 54 // MaxBlocksPerHost, if non-zero, is the max number of blocks that can be 55 // affine to each host. 56 MaxBlocksPerHost int32 `json:"maxBlocksPerHost,omitempty"` 57 } 58 59 // NewIPAMConfiguration creates a new (zeroed) IPAMConfiguration struct with the TypeMetadata initialised to the current 60 // version. 61 func NewIPAMConfiguration() *IPAMConfiguration { 62 return &IPAMConfiguration{ 63 TypeMeta: metav1.TypeMeta{ 64 Kind: KindIPPool, 65 APIVersion: GroupVersionCurrent, 66 }, 67 } 68 }