Fix enumerators

main
William Beuil 2021-07-05 10:30:42 +02:00
parent b5a6bde036
commit 3c993c063c
No known key found for this signature in database
GPG Key ID: BED2072C5C2BF537
9 changed files with 49 additions and 92 deletions

View File

@ -3,7 +3,6 @@ package aws
import (
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
tf "github.com/cloudskiff/driftctl/pkg/remote/terraform"
"github.com/cloudskiff/driftctl/pkg/resource"
"github.com/cloudskiff/driftctl/pkg/resource/aws"
)
@ -11,14 +10,12 @@ import (
type EC2AmiEnumerator struct {
repository repository.EC2Repository
factory resource.ResourceFactory
providerConfig tf.TerraformProviderConfig
}
func NewEC2AmiEnumerator(repo repository.EC2Repository, factory resource.ResourceFactory, providerConfig tf.TerraformProviderConfig) *EC2AmiEnumerator {
func NewEC2AmiEnumerator(repo repository.EC2Repository, factory resource.ResourceFactory) *EC2AmiEnumerator {
return &EC2AmiEnumerator{
repository: repo,
factory: factory,
providerConfig: providerConfig,
}
}

View File

@ -3,7 +3,6 @@ package aws
import (
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
tf "github.com/cloudskiff/driftctl/pkg/remote/terraform"
"github.com/cloudskiff/driftctl/pkg/resource"
"github.com/cloudskiff/driftctl/pkg/resource/aws"
)
@ -11,14 +10,12 @@ import (
type EC2EbsSnapshotEnumerator struct {
repository repository.EC2Repository
factory resource.ResourceFactory
providerConfig tf.TerraformProviderConfig
}
func NewEC2EbsSnapshotEnumerator(repo repository.EC2Repository, factory resource.ResourceFactory, providerConfig tf.TerraformProviderConfig) *EC2EbsSnapshotEnumerator {
func NewEC2EbsSnapshotEnumerator(repo repository.EC2Repository, factory resource.ResourceFactory) *EC2EbsSnapshotEnumerator {
return &EC2EbsSnapshotEnumerator{
repository: repo,
factory: factory,
providerConfig: providerConfig,
}
}

View File

@ -3,7 +3,6 @@ package aws
import (
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
tf "github.com/cloudskiff/driftctl/pkg/remote/terraform"
"github.com/cloudskiff/driftctl/pkg/resource"
"github.com/cloudskiff/driftctl/pkg/resource/aws"
)
@ -11,14 +10,12 @@ import (
type EC2EbsVolumeEnumerator struct {
repository repository.EC2Repository
factory resource.ResourceFactory
providerConfig tf.TerraformProviderConfig
}
func NewEC2EbsVolumeEnumerator(repo repository.EC2Repository, factory resource.ResourceFactory, providerConfig tf.TerraformProviderConfig) *EC2EbsVolumeEnumerator {
func NewEC2EbsVolumeEnumerator(repo repository.EC2Repository, factory resource.ResourceFactory) *EC2EbsVolumeEnumerator {
return &EC2EbsVolumeEnumerator{
repository: repo,
factory: factory,
providerConfig: providerConfig,
}
}

View File

@ -3,7 +3,6 @@ package aws
import (
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
tf "github.com/cloudskiff/driftctl/pkg/remote/terraform"
"github.com/cloudskiff/driftctl/pkg/resource"
"github.com/cloudskiff/driftctl/pkg/resource/aws"
)
@ -11,14 +10,12 @@ import (
type EC2EipAssociationEnumerator struct {
repository repository.EC2Repository
factory resource.ResourceFactory
providerConfig tf.TerraformProviderConfig
}
func NewEC2EipAssociationEnumerator(repo repository.EC2Repository, factory resource.ResourceFactory, providerConfig tf.TerraformProviderConfig) *EC2EipAssociationEnumerator {
func NewEC2EipAssociationEnumerator(repo repository.EC2Repository, factory resource.ResourceFactory) *EC2EipAssociationEnumerator {
return &EC2EipAssociationEnumerator{
repository: repo,
factory: factory,
providerConfig: providerConfig,
}
}

View File

@ -3,7 +3,6 @@ package aws
import (
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
tf "github.com/cloudskiff/driftctl/pkg/remote/terraform"
"github.com/cloudskiff/driftctl/pkg/resource"
"github.com/cloudskiff/driftctl/pkg/resource/aws"
)
@ -11,14 +10,12 @@ import (
type EC2EipEnumerator struct {
repository repository.EC2Repository
factory resource.ResourceFactory
providerConfig tf.TerraformProviderConfig
}
func NewEC2EipEnumerator(repo repository.EC2Repository, factory resource.ResourceFactory, providerConfig tf.TerraformProviderConfig) *EC2EipEnumerator {
func NewEC2EipEnumerator(repo repository.EC2Repository, factory resource.ResourceFactory) *EC2EipEnumerator {
return &EC2EipEnumerator{
repository: repo,
factory: factory,
providerConfig: providerConfig,
}
}

View File

@ -3,7 +3,6 @@ package aws
import (
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
tf "github.com/cloudskiff/driftctl/pkg/remote/terraform"
"github.com/cloudskiff/driftctl/pkg/resource"
"github.com/cloudskiff/driftctl/pkg/resource/aws"
)
@ -11,14 +10,12 @@ import (
type EC2InstanceEnumerator struct {
repository repository.EC2Repository
factory resource.ResourceFactory
providerConfig tf.TerraformProviderConfig
}
func NewEC2InstanceEnumerator(repo repository.EC2Repository, factory resource.ResourceFactory, providerConfig tf.TerraformProviderConfig) *EC2InstanceEnumerator {
func NewEC2InstanceEnumerator(repo repository.EC2Repository, factory resource.ResourceFactory) *EC2InstanceEnumerator {
return &EC2InstanceEnumerator{
repository: repo,
factory: factory,
providerConfig: providerConfig,
}
}

View File

@ -3,7 +3,6 @@ package aws
import (
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
tf "github.com/cloudskiff/driftctl/pkg/remote/terraform"
"github.com/cloudskiff/driftctl/pkg/resource"
"github.com/cloudskiff/driftctl/pkg/resource/aws"
)
@ -11,14 +10,12 @@ import (
type EC2KeyPairEnumerator struct {
repository repository.EC2Repository
factory resource.ResourceFactory
providerConfig tf.TerraformProviderConfig
}
func NewEC2KeyPairEnumerator(repo repository.EC2Repository, factory resource.ResourceFactory, providerConfig tf.TerraformProviderConfig) *EC2KeyPairEnumerator {
func NewEC2KeyPairEnumerator(repo repository.EC2Repository, factory resource.ResourceFactory) *EC2KeyPairEnumerator {
return &EC2KeyPairEnumerator{
repository: repo,
factory: factory,
providerConfig: providerConfig,
}
}

View File

@ -67,19 +67,19 @@ func Init(version string, alerter *alerter.Alerter,
remoteLibrary.AddEnumerator(NewS3BucketMetricsEnumerator(s3Repository, factory, provider.Config))
remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketMetricResourceType, NewS3BucketMetricsDetailsFetcher(provider, deserializer))
remoteLibrary.AddEnumerator(NewEC2EbsVolumeEnumerator(ec2repository, factory, provider.Config))
remoteLibrary.AddEnumerator(NewEC2EbsVolumeEnumerator(ec2repository, factory))
remoteLibrary.AddDetailsFetcher(aws.AwsEbsVolumeResourceType, common.NewGenericDetailsFetcher(aws.AwsEbsVolumeResourceType, provider, deserializer))
remoteLibrary.AddEnumerator(NewEC2EbsSnapshotEnumerator(ec2repository, factory, provider.Config))
remoteLibrary.AddEnumerator(NewEC2EbsSnapshotEnumerator(ec2repository, factory))
remoteLibrary.AddDetailsFetcher(aws.AwsEbsSnapshotResourceType, common.NewGenericDetailsFetcher(aws.AwsEbsSnapshotResourceType, provider, deserializer))
remoteLibrary.AddEnumerator(NewEC2EipEnumerator(ec2repository, factory, provider.Config))
remoteLibrary.AddEnumerator(NewEC2EipEnumerator(ec2repository, factory))
remoteLibrary.AddDetailsFetcher(aws.AwsEipResourceType, common.NewGenericDetailsFetcher(aws.AwsEipResourceType, provider, deserializer))
remoteLibrary.AddEnumerator(NewEC2AmiEnumerator(ec2repository, factory, provider.Config))
remoteLibrary.AddEnumerator(NewEC2AmiEnumerator(ec2repository, factory))
remoteLibrary.AddDetailsFetcher(aws.AwsAmiResourceType, common.NewGenericDetailsFetcher(aws.AwsAmiResourceType, provider, deserializer))
remoteLibrary.AddEnumerator(NewEC2KeyPairEnumerator(ec2repository, factory, provider.Config))
remoteLibrary.AddEnumerator(NewEC2KeyPairEnumerator(ec2repository, factory))
remoteLibrary.AddDetailsFetcher(aws.AwsKeyPairResourceType, common.NewGenericDetailsFetcher(aws.AwsKeyPairResourceType, provider, deserializer))
remoteLibrary.AddEnumerator(NewEC2EipAssociationEnumerator(ec2repository, factory, provider.Config))
remoteLibrary.AddEnumerator(NewEC2EipAssociationEnumerator(ec2repository, factory))
remoteLibrary.AddDetailsFetcher(aws.AwsEipAssociationResourceType, common.NewGenericDetailsFetcher(aws.AwsEipAssociationResourceType, provider, deserializer))
remoteLibrary.AddEnumerator(NewEC2InstanceEnumerator(ec2repository, factory, provider.Config))
remoteLibrary.AddEnumerator(NewEC2InstanceEnumerator(ec2repository, factory))
remoteLibrary.AddDetailsFetcher(aws.AwsInstanceResourceType, NewEC2InstanceDetailsFetcher(provider, deserializer))
supplierLibrary.AddSupplier(NewS3BucketAnalyticSupplier(provider, s3Repository, deserializer))

View File

@ -13,7 +13,6 @@ import (
"github.com/cloudskiff/driftctl/pkg/remote/cache"
"github.com/cloudskiff/driftctl/pkg/remote/common"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error"
tf "github.com/cloudskiff/driftctl/pkg/remote/terraform"
"github.com/cloudskiff/driftctl/pkg/resource"
resourceaws "github.com/cloudskiff/driftctl/pkg/resource/aws"
"github.com/cloudskiff/driftctl/pkg/terraform"
@ -98,10 +97,7 @@ func TestEC2EbsVolume(t *testing.T) {
repo = repository.NewEC2Repository(sess, cache.New(0))
}
remoteLibrary.AddEnumerator(aws.NewEC2EbsVolumeEnumerator(repo, factory, tf.TerraformProviderConfig{
Name: "test",
DefaultAlias: "eu-west-3",
}))
remoteLibrary.AddEnumerator(aws.NewEC2EbsVolumeEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsVolumeResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEbsVolumeResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
@ -189,10 +185,7 @@ func TestEC2EbsSnapshot(t *testing.T) {
repo = repository.NewEC2Repository(sess, cache.New(0))
}
remoteLibrary.AddEnumerator(aws.NewEC2EbsSnapshotEnumerator(repo, factory, tf.TerraformProviderConfig{
Name: "test",
DefaultAlias: "eu-west-3",
}))
remoteLibrary.AddEnumerator(aws.NewEC2EbsSnapshotEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsSnapshotResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEbsSnapshotResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
@ -280,10 +273,7 @@ func TestEC2Eip(t *testing.T) {
repo = repository.NewEC2Repository(sess, cache.New(0))
}
remoteLibrary.AddEnumerator(aws.NewEC2EipEnumerator(repo, factory, tf.TerraformProviderConfig{
Name: "test",
DefaultAlias: "eu-west-3",
}))
remoteLibrary.AddEnumerator(aws.NewEC2EipEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsEipResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEipResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
@ -371,10 +361,7 @@ func TestEC2Ami(t *testing.T) {
repo = repository.NewEC2Repository(sess, cache.New(0))
}
remoteLibrary.AddEnumerator(aws.NewEC2AmiEnumerator(repo, factory, tf.TerraformProviderConfig{
Name: "test",
DefaultAlias: "eu-west-3",
}))
remoteLibrary.AddEnumerator(aws.NewEC2AmiEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsAmiResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsAmiResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
@ -462,10 +449,7 @@ func TestEC2KeyPair(t *testing.T) {
repo = repository.NewEC2Repository(sess, cache.New(0))
}
remoteLibrary.AddEnumerator(aws.NewEC2KeyPairEnumerator(repo, factory, tf.TerraformProviderConfig{
Name: "test",
DefaultAlias: "eu-west-3",
}))
remoteLibrary.AddEnumerator(aws.NewEC2KeyPairEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsKeyPairResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsKeyPairResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
@ -552,10 +536,7 @@ func TestEC2EipAssociation(t *testing.T) {
repo = repository.NewEC2Repository(sess, cache.New(0))
}
remoteLibrary.AddEnumerator(aws.NewEC2EipAssociationEnumerator(repo, factory, tf.TerraformProviderConfig{
Name: "test",
DefaultAlias: "eu-west-3",
}))
remoteLibrary.AddEnumerator(aws.NewEC2EipAssociationEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsEipAssociationResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEipAssociationResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
@ -653,10 +634,7 @@ func TestEC2Instance(t *testing.T) {
repo = repository.NewEC2Repository(sess, cache.New(0))
}
remoteLibrary.AddEnumerator(aws.NewEC2InstanceEnumerator(repo, factory, tf.TerraformProviderConfig{
Name: "test",
DefaultAlias: "eu-west-3",
}))
remoteLibrary.AddEnumerator(aws.NewEC2InstanceEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsInstanceResourceType, aws.NewEC2InstanceDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)