From 31f42c7da1f4277936316f9e08b86f20bd2ffbb3 Mon Sep 17 00:00:00 2001 From: Will Haines Date: Tue, 26 Oct 2021 14:22:02 -0600 Subject: [PATCH] installconfig/vsphere: add ResourcePool to Finder The new Finder interface allows for mocking during test, but did not previously include the ResourcePool method. --- pkg/asset/installconfig/vsphere/client.go | 1 + .../vsphere/mock/vsphereclient_mock.go | 15 +++++++++++++++ pkg/asset/installconfig/vsphere/validation.go | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pkg/asset/installconfig/vsphere/client.go b/pkg/asset/installconfig/vsphere/client.go index af3287a95e4..1a53a7c7f47 100644 --- a/pkg/asset/installconfig/vsphere/client.go +++ b/pkg/asset/installconfig/vsphere/client.go @@ -21,6 +21,7 @@ type Finder interface { Folder(ctx context.Context, path string) (*object.Folder, error) NetworkList(ctx context.Context, path string) ([]object.NetworkReference, error) Network(ctx context.Context, path string) (object.NetworkReference, error) + ResourcePool(ctx context.Context, path string) (*object.ResourcePool, error) } // NewFinder creates a new client that conforms with the Finder interface and returns a diff --git a/pkg/asset/installconfig/vsphere/mock/vsphereclient_mock.go b/pkg/asset/installconfig/vsphere/mock/vsphereclient_mock.go index fb10750efd6..5913e60e4b3 100644 --- a/pkg/asset/installconfig/vsphere/mock/vsphereclient_mock.go +++ b/pkg/asset/installconfig/vsphere/mock/vsphereclient_mock.go @@ -153,3 +153,18 @@ func (mr *MockFinderMockRecorder) NetworkList(arg0, arg1 interface{}) *gomock.Ca mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NetworkList", reflect.TypeOf((*MockFinder)(nil).NetworkList), arg0, arg1) } + +// ResourcePool mocks base method +func (m *MockFinder) ResourcePool(arg0 context.Context, arg1 string) (*object.ResourcePool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ResourcePool", arg0, arg1) + ret0, _ := ret[0].(*object.ResourcePool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ResourcePool indicates an expected call of ResourcePool +func (mr *MockFinderMockRecorder) ResourcePool(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResourcePool", reflect.TypeOf((*MockFinder)(nil).ResourcePool), arg0, arg1) +} diff --git a/pkg/asset/installconfig/vsphere/validation.go b/pkg/asset/installconfig/vsphere/validation.go index 49eca3b398e..18a52083c98 100644 --- a/pkg/asset/installconfig/vsphere/validation.go +++ b/pkg/asset/installconfig/vsphere/validation.go @@ -130,7 +130,7 @@ func resourcePoolExists(finder Finder, ic *types.InstallConfig, fldPath *field.P ctx, cancel := context.WithTimeout(context.TODO(), 60*time.Second) defer cancel() - if _, err = finder.ResourcePool(ctx, cfg.ResourcePool); err != nil { + if _, err := finder.ResourcePool(ctx, cfg.ResourcePool); err != nil { return append(allErrs, field.Invalid(fldPath, cfg.ResourcePool, err.Error())) } return nil