diff --git a/providers/terraform/connection/connection.go b/providers/terraform/connection/connection.go index 5447dcaa57..c8607646f7 100644 --- a/providers/terraform/connection/connection.go +++ b/providers/terraform/connection/connection.go @@ -7,6 +7,7 @@ import ( "github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2/hclparse" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" ) type ConnectionType string @@ -15,7 +16,7 @@ type ConnectionType string // - https://www.terraform.io/docs/language/syntax/configuration.html // - https://github.com/hashicorp/hcl/blob/main/hclsyntax/spec.md type Connection struct { - id uint32 + plugin.Connection name string asset *inventory.Asset platformID string @@ -46,10 +47,6 @@ func (c *Connection) Asset() *inventory.Asset { return c.asset } -func (c *Connection) ID() uint32 { - return c.id -} - func (c *Connection) Name() string { return c.name } diff --git a/providers/terraform/connection/hcl_manifest.go b/providers/terraform/connection/hcl_manifest.go index 36c59fd818..8978fb5a1e 100644 --- a/providers/terraform/connection/hcl_manifest.go +++ b/providers/terraform/connection/hcl_manifest.go @@ -18,6 +18,7 @@ import ( "github.com/pkg/errors" "github.com/rs/zerolog/log" "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" ) @@ -133,9 +134,9 @@ func newHclConnection(id uint32, path string, asset *inventory.Asset) (*Connecti } return &Connection{ - id: id, - asset: asset, - assetType: assetType, + Connection: plugin.NewConnection(id, asset), + asset: asset, + assetType: assetType, parsed: loader.GetParser(), tfVars: tfVars, diff --git a/providers/terraform/connection/tfplan.go b/providers/terraform/connection/tfplan.go index 0be7ade6bb..e95b0a5efb 100644 --- a/providers/terraform/connection/tfplan.go +++ b/providers/terraform/connection/tfplan.go @@ -9,6 +9,7 @@ import ( "github.com/rs/zerolog/log" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" ) type Plan struct { @@ -214,9 +215,9 @@ func NewPlanConnection(id uint32, asset *inventory.Asset) (*Connection, error) { } return &Connection{ - id: id, - asset: asset, - assetType: assetType, + Connection: plugin.NewConnection(id, asset), + asset: asset, + assetType: assetType, plan: &tfPlan, }, nil diff --git a/providers/terraform/connection/tfstate.go b/providers/terraform/connection/tfstate.go index 4c3b4fcf81..48ab70f8cb 100644 --- a/providers/terraform/connection/tfstate.go +++ b/providers/terraform/connection/tfstate.go @@ -9,6 +9,7 @@ import ( "github.com/rs/zerolog/log" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" ) // This is designed around https://www.terraform.io/internals/json-format @@ -101,9 +102,9 @@ func NewStateConnection(id uint32, asset *inventory.Asset) (*Connection, error) } return &Connection{ - id: id, - asset: asset, - assetType: assetType, + Connection: plugin.NewConnection(id, asset), + asset: asset, + assetType: assetType, state: &tfState, }, nil diff --git a/providers/terraform/provider/provider.go b/providers/terraform/provider/provider.go index e8c50c1f7f..fe85c9bcbe 100644 --- a/providers/terraform/provider/provider.go +++ b/providers/terraform/provider/provider.go @@ -177,16 +177,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