Skip to content

Commit

Permalink
installconfig/vsphere: add ResourcePool to Finder
Browse files Browse the repository at this point in the history
The new Finder interface allows for mocking during test, but did not
previously include the ResourcePool method.
  • Loading branch information
willhaines committed Nov 15, 2021
1 parent aca54e3 commit 31f42c7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/asset/installconfig/vsphere/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions pkg/asset/installconfig/vsphere/mock/vsphereclient_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/asset/installconfig/vsphere/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 31f42c7

Please sign in to comment.