From 139e2723a64e59b7b2a64f1074d74532ae5d3abe Mon Sep 17 00:00:00 2001 From: Ivan Milchev Date: Mon, 12 Feb 2024 17:13:01 +0100 Subject: [PATCH] migrate vcd provider Signed-off-by: Ivan Milchev --- providers/vcd/connection/connection.go | 13 +++++-------- providers/vcd/provider/provider.go | 19 +++++++++---------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/providers/vcd/connection/connection.go b/providers/vcd/connection/connection.go index 267e740382..258e32ff08 100644 --- a/providers/vcd/connection/connection.go +++ b/providers/vcd/connection/connection.go @@ -11,11 +11,12 @@ import ( "github.com/rs/zerolog/log" "github.com/vmware/go-vcloud-director/v2/govcd" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers-sdk/v1/vault" ) type VcdConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset // custom fields @@ -25,9 +26,9 @@ type VcdConnection struct { func NewVcdConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*VcdConnection, error) { conn := &VcdConnection{ - Conf: conf, - id: id, - asset: asset, + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, } // initialize connection @@ -75,10 +76,6 @@ func (c *VcdConnection) Name() string { return "vcd" } -func (c *VcdConnection) ID() uint32 { - return c.id -} - func (c *VcdConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/vcd/provider/provider.go b/providers/vcd/provider/provider.go index fdaa94920d..625c2dc7e1 100644 --- a/providers/vcd/provider/provider.go +++ b/providers/vcd/provider/provider.go @@ -124,16 +124,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = conn.ID() - 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