@@ -57,12 +57,15 @@ import (
57
57
"sigs.k8s.io/cluster-api/util/predicates"
58
58
)
59
59
60
- var defaultAWSSecurityGroupRoles = []infrav1.SecurityGroupRole {
61
- infrav1 .SecurityGroupAPIServerLB ,
62
- infrav1 .SecurityGroupLB ,
63
- infrav1 .SecurityGroupControlPlane ,
64
- infrav1 .SecurityGroupNode ,
65
- }
60
+ var (
61
+ awsSecurityGroupRoles = []infrav1.SecurityGroupRole {
62
+ infrav1 .SecurityGroupBastion ,
63
+ infrav1 .SecurityGroupAPIServerLB ,
64
+ infrav1 .SecurityGroupLB ,
65
+ infrav1 .SecurityGroupControlPlane ,
66
+ infrav1 .SecurityGroupNode ,
67
+ }
68
+ )
66
69
67
70
// AWSClusterReconciler reconciles a AwsCluster object.
68
71
type AWSClusterReconciler struct {
@@ -100,24 +103,12 @@ func (r *AWSClusterReconciler) getNetworkService(scope scope.ClusterScope) servi
100
103
return network .NewService (& scope )
101
104
}
102
105
103
- // securityGroupRolesForCluster returns the security group roles determined by the cluster configuration.
104
- func securityGroupRolesForCluster (scope scope.ClusterScope ) []infrav1.SecurityGroupRole {
105
- roles := []infrav1.SecurityGroupRole {}
106
- // Copy to ensure we do not modify the package-level variable.
107
- copy (roles , defaultAWSSecurityGroupRoles )
108
-
109
- if scope .Bastion ().Enabled {
110
- roles = append (roles , infrav1 .SecurityGroupBastion )
111
- }
112
- return roles
113
- }
114
-
115
106
// getSecurityGroupService factory func is added for testing purpose so that we can inject mocked SecurityGroupService to the AWSClusterReconciler.
116
107
func (r * AWSClusterReconciler ) getSecurityGroupService (scope scope.ClusterScope ) services.SecurityGroupInterface {
117
108
if r .securityGroupFactory != nil {
118
109
return r .securityGroupFactory (scope )
119
110
}
120
- return securitygroup .NewService (& scope , securityGroupRolesForCluster ( scope ) )
111
+ return securitygroup .NewService (& scope , awsSecurityGroupRoles )
121
112
}
122
113
123
114
// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=awsclusters,verbs=get;list;watch;create;update;patch;delete
0 commit comments