sigs.k8s.io/cluster-api-provider-aws@v1.5.5/api/v1beta1/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 package v1beta1 17 18 import ( 19 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 20 21 clusterv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3" 22 ) 23 24 // SetDefaults_Bastion is used by defaulter-gen. 25 func SetDefaults_Bastion(obj *Bastion) { //nolint:golint,stylecheck 26 // Default to allow open access to the bastion host if no CIDR Blocks have been set 27 if len(obj.AllowedCIDRBlocks) == 0 && !obj.DisableIngressRules { 28 obj.AllowedCIDRBlocks = []string{"0.0.0.0/0"} 29 } 30 } 31 32 // SetDefaults_NetworkSpec is used by defaulter-gen. 33 func SetDefaults_NetworkSpec(obj *NetworkSpec) { //nolint:golint,stylecheck 34 // Default to Calico ingress rules if no rules have been set 35 if obj.CNI == nil { 36 obj.CNI = &CNISpec{ 37 CNIIngressRules: CNIIngressRules{ 38 { 39 Description: "bgp (calico)", 40 Protocol: SecurityGroupProtocolTCP, 41 FromPort: 179, 42 ToPort: 179, 43 }, 44 { 45 Description: "IP-in-IP (calico)", 46 Protocol: SecurityGroupProtocolIPinIP, 47 FromPort: -1, 48 ToPort: 65535, 49 }, 50 }, 51 } 52 } 53 } 54 55 // SetDefaults_AWSClusterSpec is used by defaulter-gen. 56 func SetDefaults_AWSClusterSpec(s *AWSClusterSpec) { //nolint:golint,stylecheck 57 if s.IdentityRef == nil { 58 s.IdentityRef = &AWSIdentityReference{ 59 Kind: ControllerIdentityKind, 60 Name: AWSClusterControllerIdentityName, 61 } 62 } 63 64 // If ELB scheme is set to Internet-facing due to an API bug in versions > v0.6.6 and v0.7.0, default it to internet-facing. 65 if s.ControlPlaneLoadBalancer == nil { 66 s.ControlPlaneLoadBalancer = &AWSLoadBalancerSpec{Scheme: &ClassicELBSchemeInternetFacing} 67 } else if s.ControlPlaneLoadBalancer.Scheme != nil && s.ControlPlaneLoadBalancer.Scheme.String() == ClassicELBSchemeIncorrectInternetFacing.String() { 68 s.ControlPlaneLoadBalancer.Scheme = &ClassicELBSchemeInternetFacing 69 } 70 } 71 72 // SetDefaults_Labels is used to default cluster scope resources for clusterctl move. 73 func SetDefaults_Labels(obj *metav1.ObjectMeta) { //nolint:golint,stylecheck 74 // Defaults to set label if no labels have been set 75 if obj.Labels == nil { 76 obj.Labels = map[string]string{ 77 clusterv1.ClusterctlMoveHierarchyLabelName: ""} 78 } 79 }