diff --git a/providers/aws/connection/awsec2ebsconn/provider.go b/providers/aws/connection/awsec2ebsconn/provider.go index f13534ded1..fe3f1e9877 100644 --- a/providers/aws/connection/awsec2ebsconn/provider.go +++ b/providers/aws/connection/awsec2ebsconn/provider.go @@ -32,6 +32,8 @@ const ( EBSConnectionType shared.ConnectionType = "ebs" ) +var _ plugin.Closer = (*AwsEbsConnection)(nil) + type AwsEbsConnection struct { plugin.Connection asset *inventory.Asset diff --git a/providers/azure/connection/azureinstancesnapshot/provider.go b/providers/azure/connection/azureinstancesnapshot/provider.go index d9660c25ca..2dc4221355 100644 --- a/providers/azure/connection/azureinstancesnapshot/provider.go +++ b/providers/azure/connection/azureinstancesnapshot/provider.go @@ -12,6 +12,7 @@ import ( "github.com/rs/zerolog/log" "go.mondoo.com/cnquery/v10/mrn" "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" "go.mondoo.com/cnquery/v10/providers/azure/connection/auth" "go.mondoo.com/cnquery/v10/providers/azure/connection/shared" @@ -246,6 +247,8 @@ func NewAzureSnapshotConnection(id uint32, conf *inventory.Config, asset *invent return c, nil } +var _ plugin.Closer = (*AzureSnapshotConnection)(nil) + type AzureSnapshotConnection struct { *fs.FileSystemConnection opts map[string]string diff --git a/providers/gcp/connection/gcpinstancesnapshot/provider.go b/providers/gcp/connection/gcpinstancesnapshot/provider.go index 6b943ebb37..cbecd5a1d3 100644 --- a/providers/gcp/connection/gcpinstancesnapshot/provider.go +++ b/providers/gcp/connection/gcpinstancesnapshot/provider.go @@ -11,6 +11,7 @@ import ( "github.com/rs/zerolog/log" "go.mondoo.com/cnquery/v10/mrn" "go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v10/providers-sdk/v1/plugin" "go.mondoo.com/cnquery/v10/providers/gcp/connection/shared" "go.mondoo.com/cnquery/v10/providers/os/connection/fs" "go.mondoo.com/cnquery/v10/providers/os/connection/local" @@ -252,6 +253,8 @@ func NewGcpSnapshotConnection(id uint32, conf *inventory.Config, asset *inventor return c, nil } +var _ plugin.Closer = (*GcpSnapshotConnection)(nil) + type GcpSnapshotConnection struct { *fs.FileSystemConnection opts map[string]string diff --git a/providers/os/connection/fs/filesystem.go b/providers/os/connection/fs/filesystem.go index 318b2cf1a4..0e5eee755b 100644 --- a/providers/os/connection/fs/filesystem.go +++ b/providers/os/connection/fs/filesystem.go @@ -14,7 +14,10 @@ import ( "go.mondoo.com/cnquery/v10/providers/os/fs" ) -var _ shared.Connection = &FileSystemConnection{} +var ( + _ shared.Connection = (*FileSystemConnection)(nil) + _ plugin.Closer = (*FileSystemConnection)(nil) +) func NewFileSystemConnectionWithClose(id uint32, conf *inventory.Config, asset *inventory.Asset, closeFN func()) (*FileSystemConnection, error) { path, ok := conf.Options["path"] diff --git a/providers/os/connection/local/local.go b/providers/os/connection/local/local.go index 12bc80661e..caac04cf4a 100644 --- a/providers/os/connection/local/local.go +++ b/providers/os/connection/local/local.go @@ -109,10 +109,6 @@ func (p *LocalConnection) FileInfo(path string) (shared.FileInfoDetails, error) }, nil } -func (p *LocalConnection) Close() { - // TODO: we need to close all commands and file handles -} - type CommandRunner struct { shared.Command cmdExecutor *exec.Cmd diff --git a/providers/os/connection/ssh.go b/providers/os/connection/ssh.go index 38244b8744..5c22418bd7 100644 --- a/providers/os/connection/ssh.go +++ b/providers/os/connection/ssh.go @@ -37,7 +37,10 @@ import ( "golang.org/x/crypto/ssh/knownhosts" ) -var _ shared.Connection = (*SshConnection)(nil) +var ( + _ shared.Connection = (*SshConnection)(nil) + _ plugin.Closer = (*SshConnection)(nil) +) type SshConnection struct { plugin.Connection diff --git a/providers/os/connection/tar.go b/providers/os/connection/tar.go index 01f316118a..e2585a1cc3 100644 --- a/providers/os/connection/tar.go +++ b/providers/os/connection/tar.go @@ -30,7 +30,10 @@ const ( FLATTENED_IMAGE = "flattened_path" ) -var _ shared.Connection = (*TarConnection)(nil) +var ( + _ shared.Connection = (*TarConnection)(nil) + _ plugin.Closer = (*TarConnection)(nil) +) type TarConnection struct { plugin.Connection diff --git a/providers/os/connection/winrm.go b/providers/os/connection/winrm.go index a27ffdbe4e..63a969444c 100644 --- a/providers/os/connection/winrm.go +++ b/providers/os/connection/winrm.go @@ -169,7 +169,3 @@ func (p *WinrmConnection) FileSystem() afero.Fs { } return p.fs } - -func (p *WinrmConnection) Close() { - // nothing to do yet -} diff --git a/providers/terraform/connection/connection.go b/providers/terraform/connection/connection.go index c8607646f7..22f9eeee96 100644 --- a/providers/terraform/connection/connection.go +++ b/providers/terraform/connection/connection.go @@ -12,6 +12,8 @@ import ( type ConnectionType string +var _ plugin.Closer = (*Connection)(nil) + // References: // - https://www.terraform.io/docs/language/syntax/configuration.html // - https://github.com/hashicorp/hcl/blob/main/hclsyntax/spec.md