@@ -41,7 +41,6 @@ import (
41
41
infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1beta1"
42
42
"sigs.k8s.io/cluster-api-provider-aws/feature"
43
43
"sigs.k8s.io/cluster-api-provider-aws/pkg/cloud/scope"
44
- "sigs.k8s.io/cluster-api-provider-aws/pkg/cloud/services"
45
44
"sigs.k8s.io/cluster-api-provider-aws/pkg/cloud/services/ec2"
46
45
"sigs.k8s.io/cluster-api-provider-aws/pkg/cloud/services/elb"
47
46
"sigs.k8s.io/cluster-api-provider-aws/pkg/cloud/services/instancestate"
69
68
// AWSClusterReconciler reconciles a AwsCluster object.
70
69
type AWSClusterReconciler struct {
71
70
client.Client
72
- Recorder record.EventRecorder
73
- ec2ServiceFactory func (scope.EC2Scope ) services.EC2MachineInterface
74
- networkServiceFactory func (scope.ClusterScope ) services.NetworkInterface
75
- elbServiceFactory func (scope.ELBScope ) services.ELBInterface
76
- securityGroupFactory func (scope.ClusterScope ) services.SecurityGroupInterface
77
- Endpoints []scope.ServiceEndpoint
78
- WatchFilterValue string
79
- }
80
-
81
- // getEC2Service factory func is added for testing purpose so that we can inject mocked EC2Service to the AWSClusterReconciler.
82
- func (r * AWSClusterReconciler ) getEC2Service (scope scope.EC2Scope ) services.EC2MachineInterface {
83
- if r .ec2ServiceFactory != nil {
84
- return r .ec2ServiceFactory (scope )
85
- }
86
- return ec2 .NewService (scope )
87
- }
88
-
89
- // getELBService factory func is added for testing purpose so that we can inject mocked ELBService to the AWSClusterReconciler.
90
- func (r * AWSClusterReconciler ) getELBService (scope scope.ELBScope ) services.ELBInterface {
91
- if r .elbServiceFactory != nil {
92
- return r .elbServiceFactory (scope )
93
- }
94
- return elb .NewService (scope )
95
- }
96
-
97
- // getNetworkService factory func is added for testing purpose so that we can inject mocked NetworkService to the AWSClusterReconciler.
98
- func (r * AWSClusterReconciler ) getNetworkService (scope scope.ClusterScope ) services.NetworkInterface {
99
- if r .networkServiceFactory != nil {
100
- return r .networkServiceFactory (scope )
101
- }
102
- return network .NewService (& scope )
103
- }
104
-
105
- // getSecurityGroupService factory func is added for testing purpose so that we can inject mocked SecurityGroupService to the AWSClusterReconciler.
106
- func (r * AWSClusterReconciler ) getSecurityGroupService (scope scope.ClusterScope ) services.SecurityGroupInterface {
107
- if r .securityGroupFactory != nil {
108
- return r .securityGroupFactory (scope )
109
- }
110
- return securitygroup .NewService (& scope , awsSecurityGroupRoles )
71
+ Recorder record.EventRecorder
72
+ Endpoints []scope.ServiceEndpoint
73
+ WatchFilterValue string
111
74
}
112
75
113
76
// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=awsclusters,verbs=get;list;watch;create;update;patch;delete
@@ -196,10 +159,10 @@ func (r *AWSClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
196
159
func (r * AWSClusterReconciler ) reconcileDelete (clusterScope * scope.ClusterScope ) (reconcile.Result , error ) {
197
160
clusterScope .Info ("Reconciling AWSCluster delete" )
198
161
199
- ec2svc := r . getEC2Service (clusterScope )
200
- elbsvc := r . getELBService (clusterScope )
201
- networkSvc := r . getNetworkService ( * clusterScope )
202
- sgService := r . getSecurityGroupService ( * clusterScope )
162
+ ec2svc := ec2 . NewService (clusterScope )
163
+ elbsvc := elb . NewService (clusterScope )
164
+ networkSvc := network . NewService ( clusterScope )
165
+ sgService := securitygroup . NewService ( clusterScope , awsSecurityGroupRoles )
203
166
204
167
if feature .Gates .Enabled (feature .EventBridgeInstanceState ) {
205
168
instancestateSvc := instancestate .NewService (clusterScope )
@@ -247,10 +210,10 @@ func (r *AWSClusterReconciler) reconcileNormal(clusterScope *scope.ClusterScope)
247
210
return reconcile.Result {}, err
248
211
}
249
212
250
- ec2Service := r . getEC2Service (clusterScope )
251
- elbService := r . getELBService (clusterScope )
252
- networkSvc := r . getNetworkService ( * clusterScope )
253
- sgService := r . getSecurityGroupService ( * clusterScope )
213
+ ec2Service := ec2 . NewService (clusterScope )
214
+ elbService := elb . NewService (clusterScope )
215
+ networkSvc := network . NewService ( clusterScope )
216
+ sgService := securitygroup . NewService ( clusterScope , awsSecurityGroupRoles )
254
217
255
218
if err := networkSvc .ReconcileNetwork (); err != nil {
256
219
clusterScope .Error (err , "failed to reconcile network" )
0 commit comments