File tree Expand file tree Collapse file tree 2 files changed +15
-20
lines changed
Expand file tree Collapse file tree 2 files changed +15
-20
lines changed Original file line number Diff line number Diff line change @@ -2931,15 +2931,23 @@ func (s *ClusterScope) isResourceCreatedByController(resourceType infrav1.Resour
29312931 return false
29322932}
29332933
2934- // TODO: duplicate function, optimize it.
2935- func (s * ClusterScope ) bucketRegion () string {
2936- if s .COSInstance () != nil && s .COSInstance ().BucketRegion != "" {
2937- return s .COSInstance ().BucketRegion
2934+ func bucketRegionFrom (cos * infrav1.CosInstance , vpc * infrav1.VPCResourceReference ) string {
2935+ if cos != nil && cos .BucketRegion != "" {
2936+ return cos .BucketRegion
29382937 }
29392938 // if the bucket region is not set, use vpc region
2940- vpcDetails := s .VPC ()
2941- if vpcDetails != nil && vpcDetails .Region != nil {
2942- return * vpcDetails .Region
2939+ if vpc != nil && vpc .Region != nil {
2940+ return * vpc .Region
29432941 }
29442942 return ""
29452943}
2944+
2945+ // bucketRegion returns the region to use for COS bucket for the ClusterScope.
2946+ func (s * ClusterScope ) bucketRegion () string {
2947+ return bucketRegionFrom (s .COSInstance (), s .VPC ())
2948+ }
2949+
2950+ // bucketRegion returns the region to use for COS bucket for the MachineScope.
2951+ func (m * MachineScope ) bucketRegion () string {
2952+ return bucketRegionFrom (m .IBMPowerVSCluster .Spec .CosInstance , m .IBMPowerVSCluster .Spec .VPC )
2953+ }
Original file line number Diff line number Diff line change @@ -1145,16 +1145,3 @@ func (m *MachineScope) bucketName() string {
11451145 }
11461146 return fmt .Sprintf ("%s-%s" , m .IBMPowerVSCluster .GetName (), "cosbucket" )
11471147}
1148-
1149- // TODO: duplicate function, optimize it.
1150- func (m * MachineScope ) bucketRegion () string {
1151- if m .IBMPowerVSCluster .Spec .CosInstance != nil && m .IBMPowerVSCluster .Spec .CosInstance .BucketRegion != "" {
1152- return m .IBMPowerVSCluster .Spec .CosInstance .BucketRegion
1153- }
1154- // if the bucket region is not set, use vpc region
1155- vpcDetails := m .IBMPowerVSCluster .Spec .VPC
1156- if vpcDetails != nil && vpcDetails .Region != nil {
1157- return * vpcDetails .Region
1158- }
1159- return ""
1160- }
You can’t perform that action at this time.
0 commit comments