From 171d2122d9b7645d3e8e0bbf2270a0730eb01193 Mon Sep 17 00:00:00 2001 From: Ivan Milchev Date: Mon, 12 Feb 2024 17:14:05 +0100 Subject: [PATCH] migrate vsphere provider Signed-off-by: Ivan Milchev --- providers/vsphere/connection/connection.go | 13 +++++-------- providers/vsphere/provider/provider.go | 19 +++++++++---------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/providers/vsphere/connection/connection.go b/providers/vsphere/connection/connection.go index 3f411a9736..b6ae96fb7e 100644 --- a/providers/vsphere/connection/connection.go +++ b/providers/vsphere/connection/connection.go @@ -9,6 +9,7 @@ import ( "net/url" "strconv" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/vault" "github.com/vmware/govmomi" @@ -16,7 +17,7 @@ import ( ) type VsphereConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset client *govmomi.Client @@ -39,9 +40,9 @@ func vSphereConnectionURL(hostname string, port int32, user string, password str func NewVsphereConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*VsphereConnection, error) { conn := &VsphereConnection{ - Conf: conf, - id: id, - asset: asset, + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, } // initialize vSphere connection @@ -76,10 +77,6 @@ func (c *VsphereConnection) Name() string { return "vsphere" } -func (c *VsphereConnection) ID() uint32 { - return c.id -} - func (c *VsphereConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/vsphere/provider/provider.go b/providers/vsphere/provider/provider.go index 72f135990c..e56830a91f 100644 --- a/providers/vsphere/provider/provider.go +++ b/providers/vsphere/provider/provider.go @@ -154,16 +154,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = connId - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err