Skip to content

Commit

Permalink
migrate vsphere provider
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev committed Feb 12, 2024
1 parent 139e272 commit 171d212
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
13 changes: 5 additions & 8 deletions providers/vsphere/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ 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"
"go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory"
)

type VsphereConnection struct {
id uint32
plugin.Connection
Conf *inventory.Config
asset *inventory.Asset
client *govmomi.Client
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
19 changes: 9 additions & 10 deletions providers/vsphere/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 171d212

Please sign in to comment.