@@ -217,7 +217,7 @@ func (a *AWSHubActuator) ensureHostedZone(cd *hivev1.ClusterDeployment, metadata
217
217
return false , "" , err
218
218
}
219
219
220
- newHzID , err := a .createHostedZone (& selectedVPC , apiDomain )
220
+ newHzID , err := a .createHostedZone (selectedVPC , apiDomain )
221
221
if err != nil {
222
222
return false , "" , err
223
223
}
@@ -713,9 +713,7 @@ func (a *AWSHubActuator) getEndpointVPC(cd *hivev1.ClusterDeployment, metadata *
713
713
return endpointVPC , nil
714
714
}
715
715
716
- func (a * AWSHubActuator ) selectHostedZoneVPC (cd * hivev1.ClusterDeployment , metadata * hivev1.ClusterMetadata , logger log.FieldLogger ) (hivev1.AWSAssociatedVPC , error ) {
717
- selectedVPC := hivev1.AWSAssociatedVPC {}
718
-
716
+ func (a * AWSHubActuator ) selectHostedZoneVPC (cd * hivev1.ClusterDeployment , metadata * hivev1.ClusterMetadata , logger log.FieldLogger ) (* hivev1.AWSAssociatedVPC , error ) {
719
717
// For clusterdeployments that are on AWS, use the VPCEndpoint VPC
720
718
if cd .Status .Platform != nil &&
721
719
cd .Status .Platform .AWS != nil &&
@@ -724,29 +722,29 @@ func (a *AWSHubActuator) selectHostedZoneVPC(cd *hivev1.ClusterDeployment, metad
724
722
725
723
endpointVPC , err := a .getEndpointVPC (cd , metadata )
726
724
if err != nil {
727
- return selectedVPC , errors .Wrap (err , "error getting Endpoint VPC" )
725
+ return nil , errors .Wrap (err , "error getting Endpoint VPC" )
728
726
}
729
727
730
728
if endpointVPC .VPCID == "" {
731
- return selectedVPC , errors .New ("unable to select Endpoint VPC: Endpoint not found" )
729
+ return nil , errors .New ("unable to select Endpoint VPC: Endpoint not found" )
732
730
}
733
731
734
- return endpointVPC , nil
732
+ return & endpointVPC , nil
735
733
}
736
734
737
735
associatedVPCS , err := a .getAssociatedVPCs (cd , metadata , logger )
738
736
if err != nil {
739
- return selectedVPC , errors .Wrap (err , "error getting associated VPCs" )
737
+ return nil , errors .Wrap (err , "error getting associated VPCs" )
740
738
}
741
739
742
740
// Select the first associatedVPC that uses the primary AWS PrivateLink credential.
743
741
// This is necessary because a Hosted Zone can only be created using a VPC owned by the same account.
744
742
for _ , associatedVPC := range associatedVPCS {
745
743
if associatedVPC .CredentialsSecretRef == nil || * associatedVPC .CredentialsSecretRef == a .config .CredentialsSecretRef {
746
- return associatedVPC , nil
744
+ return & associatedVPC , nil
747
745
}
748
746
}
749
747
750
748
// No VPCs found that match the criteria, return an error.
751
- return selectedVPC , errors .New ("unable to find an associatedVPC that uses the primary AWS PrivateLink credentials" )
749
+ return nil , errors .New ("unable to find an associatedVPC that uses the primary AWS PrivateLink credentials" )
752
750
}
0 commit comments