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,22 +3,19 @@ package aws
import ( import (
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository" "github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error" 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"
"github.com/cloudskiff/driftctl/pkg/resource/aws" "github.com/cloudskiff/driftctl/pkg/resource/aws"
) )
type EC2AmiEnumerator struct { type EC2AmiEnumerator struct {
repository repository.EC2Repository repository repository.EC2Repository
factory resource.ResourceFactory 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{ return &EC2AmiEnumerator{
repository: repo, repository: repo,
factory: factory, factory: factory,
providerConfig: providerConfig,
} }
} }

View File

@ -3,22 +3,19 @@ package aws
import ( import (
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository" "github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error" 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"
"github.com/cloudskiff/driftctl/pkg/resource/aws" "github.com/cloudskiff/driftctl/pkg/resource/aws"
) )
type EC2EbsSnapshotEnumerator struct { type EC2EbsSnapshotEnumerator struct {
repository repository.EC2Repository repository repository.EC2Repository
factory resource.ResourceFactory 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{ return &EC2EbsSnapshotEnumerator{
repository: repo, repository: repo,
factory: factory, factory: factory,
providerConfig: providerConfig,
} }
} }

View File

@ -3,22 +3,19 @@ package aws
import ( import (
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository" "github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error" 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"
"github.com/cloudskiff/driftctl/pkg/resource/aws" "github.com/cloudskiff/driftctl/pkg/resource/aws"
) )
type EC2EbsVolumeEnumerator struct { type EC2EbsVolumeEnumerator struct {
repository repository.EC2Repository repository repository.EC2Repository
factory resource.ResourceFactory 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{ return &EC2EbsVolumeEnumerator{
repository: repo, repository: repo,
factory: factory, factory: factory,
providerConfig: providerConfig,
} }
} }

View File

@ -3,22 +3,19 @@ package aws
import ( import (
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository" "github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error" 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"
"github.com/cloudskiff/driftctl/pkg/resource/aws" "github.com/cloudskiff/driftctl/pkg/resource/aws"
) )
type EC2EipAssociationEnumerator struct { type EC2EipAssociationEnumerator struct {
repository repository.EC2Repository repository repository.EC2Repository
factory resource.ResourceFactory 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{ return &EC2EipAssociationEnumerator{
repository: repo, repository: repo,
factory: factory, factory: factory,
providerConfig: providerConfig,
} }
} }

View File

@ -3,22 +3,19 @@ package aws
import ( import (
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository" "github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error" 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"
"github.com/cloudskiff/driftctl/pkg/resource/aws" "github.com/cloudskiff/driftctl/pkg/resource/aws"
) )
type EC2EipEnumerator struct { type EC2EipEnumerator struct {
repository repository.EC2Repository repository repository.EC2Repository
factory resource.ResourceFactory 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{ return &EC2EipEnumerator{
repository: repo, repository: repo,
factory: factory, factory: factory,
providerConfig: providerConfig,
} }
} }

View File

@ -3,22 +3,19 @@ package aws
import ( import (
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository" "github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error" 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"
"github.com/cloudskiff/driftctl/pkg/resource/aws" "github.com/cloudskiff/driftctl/pkg/resource/aws"
) )
type EC2InstanceEnumerator struct { type EC2InstanceEnumerator struct {
repository repository.EC2Repository repository repository.EC2Repository
factory resource.ResourceFactory 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{ return &EC2InstanceEnumerator{
repository: repo, repository: repo,
factory: factory, factory: factory,
providerConfig: providerConfig,
} }
} }

View File

@ -3,22 +3,19 @@ package aws
import ( import (
"github.com/cloudskiff/driftctl/pkg/remote/aws/repository" "github.com/cloudskiff/driftctl/pkg/remote/aws/repository"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error" 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"
"github.com/cloudskiff/driftctl/pkg/resource/aws" "github.com/cloudskiff/driftctl/pkg/resource/aws"
) )
type EC2KeyPairEnumerator struct { type EC2KeyPairEnumerator struct {
repository repository.EC2Repository repository repository.EC2Repository
factory resource.ResourceFactory 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{ return &EC2KeyPairEnumerator{
repository: repo, repository: repo,
factory: factory, 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.AddEnumerator(NewS3BucketMetricsEnumerator(s3Repository, factory, provider.Config))
remoteLibrary.AddDetailsFetcher(aws.AwsS3BucketMetricResourceType, NewS3BucketMetricsDetailsFetcher(provider, deserializer)) 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.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.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.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.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.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.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)) remoteLibrary.AddDetailsFetcher(aws.AwsInstanceResourceType, NewEC2InstanceDetailsFetcher(provider, deserializer))
supplierLibrary.AddSupplier(NewS3BucketAnalyticSupplier(provider, s3Repository, 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/cache"
"github.com/cloudskiff/driftctl/pkg/remote/common" "github.com/cloudskiff/driftctl/pkg/remote/common"
remoteerror "github.com/cloudskiff/driftctl/pkg/remote/error" 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"
resourceaws "github.com/cloudskiff/driftctl/pkg/resource/aws" resourceaws "github.com/cloudskiff/driftctl/pkg/resource/aws"
"github.com/cloudskiff/driftctl/pkg/terraform" "github.com/cloudskiff/driftctl/pkg/terraform"
@ -98,10 +97,7 @@ func TestEC2EbsVolume(t *testing.T) {
repo = repository.NewEC2Repository(sess, cache.New(0)) repo = repository.NewEC2Repository(sess, cache.New(0))
} }
remoteLibrary.AddEnumerator(aws.NewEC2EbsVolumeEnumerator(repo, factory, tf.TerraformProviderConfig{ remoteLibrary.AddEnumerator(aws.NewEC2EbsVolumeEnumerator(repo, factory))
Name: "test",
DefaultAlias: "eu-west-3",
}))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsVolumeResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEbsVolumeResourceType, provider, deserializer)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsVolumeResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEbsVolumeResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions) s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
@ -189,10 +185,7 @@ func TestEC2EbsSnapshot(t *testing.T) {
repo = repository.NewEC2Repository(sess, cache.New(0)) repo = repository.NewEC2Repository(sess, cache.New(0))
} }
remoteLibrary.AddEnumerator(aws.NewEC2EbsSnapshotEnumerator(repo, factory, tf.TerraformProviderConfig{ remoteLibrary.AddEnumerator(aws.NewEC2EbsSnapshotEnumerator(repo, factory))
Name: "test",
DefaultAlias: "eu-west-3",
}))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsSnapshotResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEbsSnapshotResourceType, provider, deserializer)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsSnapshotResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEbsSnapshotResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions) s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
@ -280,10 +273,7 @@ func TestEC2Eip(t *testing.T) {
repo = repository.NewEC2Repository(sess, cache.New(0)) repo = repository.NewEC2Repository(sess, cache.New(0))
} }
remoteLibrary.AddEnumerator(aws.NewEC2EipEnumerator(repo, factory, tf.TerraformProviderConfig{ remoteLibrary.AddEnumerator(aws.NewEC2EipEnumerator(repo, factory))
Name: "test",
DefaultAlias: "eu-west-3",
}))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsEipResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEipResourceType, provider, deserializer)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsEipResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEipResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions) s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
@ -371,10 +361,7 @@ func TestEC2Ami(t *testing.T) {
repo = repository.NewEC2Repository(sess, cache.New(0)) repo = repository.NewEC2Repository(sess, cache.New(0))
} }
remoteLibrary.AddEnumerator(aws.NewEC2AmiEnumerator(repo, factory, tf.TerraformProviderConfig{ remoteLibrary.AddEnumerator(aws.NewEC2AmiEnumerator(repo, factory))
Name: "test",
DefaultAlias: "eu-west-3",
}))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsAmiResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsAmiResourceType, provider, deserializer)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsAmiResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsAmiResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions) s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
@ -462,10 +449,7 @@ func TestEC2KeyPair(t *testing.T) {
repo = repository.NewEC2Repository(sess, cache.New(0)) repo = repository.NewEC2Repository(sess, cache.New(0))
} }
remoteLibrary.AddEnumerator(aws.NewEC2KeyPairEnumerator(repo, factory, tf.TerraformProviderConfig{ remoteLibrary.AddEnumerator(aws.NewEC2KeyPairEnumerator(repo, factory))
Name: "test",
DefaultAlias: "eu-west-3",
}))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsKeyPairResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsKeyPairResourceType, provider, deserializer)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsKeyPairResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsKeyPairResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions) s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
@ -552,10 +536,7 @@ func TestEC2EipAssociation(t *testing.T) {
repo = repository.NewEC2Repository(sess, cache.New(0)) repo = repository.NewEC2Repository(sess, cache.New(0))
} }
remoteLibrary.AddEnumerator(aws.NewEC2EipAssociationEnumerator(repo, factory, tf.TerraformProviderConfig{ remoteLibrary.AddEnumerator(aws.NewEC2EipAssociationEnumerator(repo, factory))
Name: "test",
DefaultAlias: "eu-west-3",
}))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsEipAssociationResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEipAssociationResourceType, provider, deserializer)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsEipAssociationResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEipAssociationResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions) s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
@ -653,10 +634,7 @@ func TestEC2Instance(t *testing.T) {
repo = repository.NewEC2Repository(sess, cache.New(0)) repo = repository.NewEC2Repository(sess, cache.New(0))
} }
remoteLibrary.AddEnumerator(aws.NewEC2InstanceEnumerator(repo, factory, tf.TerraformProviderConfig{ remoteLibrary.AddEnumerator(aws.NewEC2InstanceEnumerator(repo, factory))
Name: "test",
DefaultAlias: "eu-west-3",
}))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsInstanceResourceType, aws.NewEC2InstanceDetailsFetcher(provider, deserializer)) remoteLibrary.AddDetailsFetcher(resourceaws.AwsInstanceResourceType, aws.NewEC2InstanceDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions) s := NewScanner(nil, remoteLibrary, alerter, scanOptions)