sigs.k8s.io/cluster-api-provider-aws@v1.5.5/api/v1alpha4/defaults.go (about) 1 /* 2 Copyright 2021 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1alpha4 18 19 import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 22 clusterv1alpha4 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3" 23 ) 24 25 // SetDefaults_Bastion is used by defaulter-gen. 26 func SetDefaults_Bastion(obj *Bastion) { //nolint:golint,stylecheck 27 // Default to allow open access to the bastion host if no CIDR Blocks have been set 28 if len(obj.AllowedCIDRBlocks) == 0 && !obj.DisableIngressRules { 29 obj.AllowedCIDRBlocks = []string{"0.0.0.0/0"} 30 } 31 } 32 33 // SetDefaults_NetworkSpec is used by defaulter-gen. 34 func SetDefaults_NetworkSpec(obj *NetworkSpec) { //nolint:golint,stylecheck 35 // Default to Calico ingress rules if no rules have been set 36 if obj.CNI == nil { 37 obj.CNI = &CNISpec{ 38 CNIIngressRules: CNIIngressRules{ 39 { 40 Description: "bgp (calico)", 41 Protocol: SecurityGroupProtocolTCP, 42 FromPort: 179, 43 ToPort: 179, 44 }, 45 { 46 Description: "IP-in-IP (calico)", 47 Protocol: SecurityGroupProtocolIPinIP, 48 FromPort: -1, 49 ToPort: 65535, 50 }, 51 }, 52 } 53 } 54 } 55 56 // SetDefaults_Labels is used by defaulter-gen. 57 func SetDefaults_Labels(obj *metav1.ObjectMeta) { //nolint:golint,stylecheck 58 // Defaults to set label if no labels have been set 59 if obj.Labels == nil { 60 obj.Labels = map[string]string{ 61 clusterv1alpha4.ClusterctlMoveHierarchyLabelName: "", 62 } 63 } 64 }