From e7000af52ab4ed7ce6aecb634bbed56c4ee26a4a Mon Sep 17 00:00:00 2001 From: Shilpa-Gokul Date: Fri, 17 May 2024 16:27:39 +0530 Subject: [PATCH] Rename the function name --- cloud/scope/powervs_cluster.go | 4 ++-- .../services/powervs/mock/powervs_generated.go | 14 +++++++------- pkg/cloud/services/powervs/powervs.go | 2 +- pkg/cloud/services/powervs/service.go | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cloud/scope/powervs_cluster.go b/cloud/scope/powervs_cluster.go index db6b9c1b7..483bd234e 100644 --- a/cloud/scope/powervs_cluster.go +++ b/cloud/scope/powervs_cluster.go @@ -592,12 +592,12 @@ func (s *PowerVSClusterScope) IsPowerVSZoneSupportsPER() error { return fmt.Errorf("powervs zone is not set") } // fetch the datacenter capabilities for zone. - datacenter, err := s.IBMPowerVSClient.GetDatacenters(*zone) + datacenterCapabilities, err := s.IBMPowerVSClient.GetDatacenterCapabilities(*zone) if err != nil { return err } // check for the PER support in datacenter capabilities. - perAvailable, ok := datacenter.Capabilities[powerEdgeRouter] + perAvailable, ok := datacenterCapabilities[powerEdgeRouter] if !ok { return fmt.Errorf("%s capability unknown for zone: %s", powerEdgeRouter, *zone) } diff --git a/pkg/cloud/services/powervs/mock/powervs_generated.go b/pkg/cloud/services/powervs/mock/powervs_generated.go index 9b9271548..86cf76be7 100644 --- a/pkg/cloud/services/powervs/mock/powervs_generated.go +++ b/pkg/cloud/services/powervs/mock/powervs_generated.go @@ -246,19 +246,19 @@ func (mr *MockPowerVSMockRecorder) GetDHCPServer(id any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDHCPServer", reflect.TypeOf((*MockPowerVS)(nil).GetDHCPServer), id) } -// GetDatacenters mocks base method. -func (m *MockPowerVS) GetDatacenters(zone string) (*models.Datacenter, error) { +// GetDatacenterCapabilities mocks base method. +func (m *MockPowerVS) GetDatacenterCapabilities(zone string) (map[string]bool, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetDatacenters", zone) - ret0, _ := ret[0].(*models.Datacenter) + ret := m.ctrl.Call(m, "GetDatacenterCapabilities", zone) + ret0, _ := ret[0].(map[string]bool) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetDatacenters indicates an expected call of GetDatacenters. -func (mr *MockPowerVSMockRecorder) GetDatacenters(zone any) *gomock.Call { +// GetDatacenterCapabilities indicates an expected call of GetDatacenterCapabilities. +func (mr *MockPowerVSMockRecorder) GetDatacenterCapabilities(zone any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDatacenters", reflect.TypeOf((*MockPowerVS)(nil).GetDatacenters), zone) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDatacenterCapabilities", reflect.TypeOf((*MockPowerVS)(nil).GetDatacenterCapabilities), zone) } // GetImage mocks base method. diff --git a/pkg/cloud/services/powervs/powervs.go b/pkg/cloud/services/powervs/powervs.go index 049225c17..b6e1736c7 100644 --- a/pkg/cloud/services/powervs/powervs.go +++ b/pkg/cloud/services/powervs/powervs.go @@ -44,5 +44,5 @@ type PowerVS interface { DeleteDHCPServer(id string) error WithClients(options ServiceOptions) *Service GetNetworkByName(networkName string) (*models.NetworkReference, error) - GetDatacenters(zone string) (*models.Datacenter, error) + GetDatacenterCapabilities(zone string) (map[string]bool, error) } diff --git a/pkg/cloud/services/powervs/service.go b/pkg/cloud/services/powervs/service.go index 015bc32b1..08f14928f 100644 --- a/pkg/cloud/services/powervs/service.go +++ b/pkg/cloud/services/powervs/service.go @@ -188,8 +188,8 @@ func (s *Service) GetNetworkByName(networkName string) (*models.NetworkReference return network, nil } -// GetDatacenters fetches the datacenter capabilities for the given zone. -func (s *Service) GetDatacenters(zone string) (*models.Datacenter, error) { +// GetDatacenterCapabilities fetches the datacenter capabilities for the given zone. +func (s *Service) GetDatacenterCapabilities(zone string) (map[string]bool, error) { // though the function name is WithDatacenterRegion it takes zone as parameter params := datacenters.NewV1DatacentersGetParamsWithContext(context.TODO()).WithDatacenterRegion(zone) datacenter, err := s.session.Power.Datacenters.V1DatacentersGet(params) @@ -199,5 +199,5 @@ func (s *Service) GetDatacenters(zone string) (*models.Datacenter, error) { if datacenter == nil || datacenter.Payload == nil || datacenter.Payload.Capabilities == nil { return nil, fmt.Errorf("failed to get datacenter capabilities for zone: %s", zone) } - return datacenter.Payload, nil + return datacenter.Payload.Capabilities, nil }