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