Remove dead code since deep mode refactoring is complete

main
Elie 2021-07-26 12:09:52 +02:00
parent b63d807430
commit c735d1f1ad
No known key found for this signature in database
GPG Key ID: 399AF69092C727B6
23 changed files with 62 additions and 122 deletions

View File

@ -197,7 +197,6 @@ func scanRun(opts *pkg.ScanOptions) error {
alerter := alerter.NewAlerter()
providerLibrary := terraform.NewProviderLibrary()
supplierLibrary := resource.NewSupplierLibrary()
remoteLibrary := common.NewRemoteLibrary()
iacProgress := globaloutput.NewProgress("Scanning states", "Scanned states", true)
@ -207,7 +206,7 @@ func scanRun(opts *pkg.ScanOptions) error {
resFactory := terraform.NewTerraformResourceFactory(resourceSchemaRepository)
err := remote.Activate(opts.To, opts.ProviderVersion, alerter, providerLibrary, supplierLibrary, remoteLibrary, scanProgress, resourceSchemaRepository, resFactory, opts.ConfigDir)
err := remote.Activate(opts.To, opts.ProviderVersion, alerter, providerLibrary, remoteLibrary, scanProgress, resourceSchemaRepository, resFactory, opts.ConfigDir)
if err != nil {
return err
}
@ -219,7 +218,7 @@ func scanRun(opts *pkg.ScanOptions) error {
logrus.Trace("Exited")
}()
scanner := remote.NewScanner(supplierLibrary.Suppliers(), remoteLibrary, alerter, remote.ScannerOptions{Deep: opts.Deep})
scanner := remote.NewScanner(remoteLibrary, alerter, remote.ScannerOptions{Deep: opts.Deep})
iacSupplier, err := supplier.GetIACSupplier(opts.From, providerLibrary, opts.BackendOptions, iacProgress, resFactory)
if err != nil {

View File

@ -21,7 +21,6 @@ const RemoteAWSTerraform = "aws+tf"
func Init(version string, alerter *alerter.Alerter,
providerLibrary *terraform.ProviderLibrary,
supplierLibrary *resource.SupplierLibrary,
remoteLibrary *common.RemoteLibrary,
progress output.Progress,
resourceSchemaRepository *resource.SchemaRepository,

View File

@ -100,7 +100,7 @@ func TestCloudfrontDistribution(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewCloudfrontDistributionEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsCloudfrontDistributionResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsCloudfrontDistributionResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {

View File

@ -103,7 +103,7 @@ func TestDynamoDBTable(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewDynamoDBTableEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsDynamodbTableResourceType, aws.NewDynamoDBTableDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, c.wantErr, err)
if err != nil {

View File

@ -101,7 +101,7 @@ func TestEC2EbsVolume(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewEC2EbsVolumeEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsVolumeResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEbsVolumeResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -190,7 +190,7 @@ func TestEC2EbsSnapshot(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewEC2EbsSnapshotEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsEbsSnapshotResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEbsSnapshotResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -279,7 +279,7 @@ func TestEC2Eip(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewEC2EipEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsEipResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEipResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -368,7 +368,7 @@ func TestEC2Ami(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewEC2AmiEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsAmiResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsAmiResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -457,7 +457,7 @@ func TestEC2KeyPair(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewEC2KeyPairEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsKeyPairResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsKeyPairResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -548,7 +548,7 @@ func TestEC2EipAssociation(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewEC2EipAssociationEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsEipAssociationResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEipAssociationResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -647,7 +647,7 @@ func TestEC2Instance(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewEC2InstanceEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsInstanceResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsInstanceResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -736,7 +736,7 @@ func TestEC2InternetGateway(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewEC2InternetGatewayEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsInternetGatewayResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsInternetGatewayResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -842,7 +842,7 @@ func TestVPC(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewVPCEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsVpcResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsVpcResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -945,7 +945,7 @@ func TestDefaultVPC(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewDefaultVPCEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultVpcResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultVpcResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -1103,7 +1103,7 @@ func TestEC2RouteTableAssociation(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewEC2RouteTableAssociationEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteTableAssociationResourceType, aws.NewEC2RouteTableAssociationDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -1215,7 +1215,7 @@ func TestEC2Subnet(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewEC2SubnetEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsSubnetResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSubnetResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -1327,7 +1327,7 @@ func TestEC2DefaultSubnet(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewEC2DefaultSubnetEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultSubnetResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultSubnetResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -1426,7 +1426,7 @@ func TestEC2RouteTable(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewEC2RouteTableEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteTableResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRouteTableResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -1525,7 +1525,7 @@ func TestEC2DefaultRouteTable(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewEC2DefaultRouteTableEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultRouteTableResourceType, aws.NewEC2DefaultRouteTableDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -1624,7 +1624,7 @@ func TestVpcSecurityGroup(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewVPCSecurityGroupEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsSecurityGroupResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSecurityGroupResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -1723,7 +1723,7 @@ func TestVpcDefaultSecurityGroup(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewVPCDefaultSecurityGroupEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsDefaultSecurityGroupResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDefaultSecurityGroupResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -1811,7 +1811,7 @@ func TestEC2NatGateway(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewEC2NatGatewayEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsNatGatewayResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsNatGatewayResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -1972,7 +1972,7 @@ func TestEC2Route(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewEC2RouteEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsRouteResourceType, aws.NewEC2RouteDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -2155,7 +2155,7 @@ func TestVpcSecurityGroupRule(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewVPCSecurityGroupRuleEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsSecurityGroupRuleResourceType, aws.NewVPCSecurityGroupRuleDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, c.wantErr, err)
if err != nil {

View File

@ -103,7 +103,7 @@ func TestECRRepository(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewECRRepositoryEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsEcrRepositoryResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsEcrRepositoryResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.err)
if err != nil {

View File

@ -19,7 +19,6 @@ const RemoteGithubTerraform = "github+tf"
func Init(version string, alerter *alerter.Alerter,
providerLibrary *terraform.ProviderLibrary,
supplierLibrary *resource.SupplierLibrary,
remoteLibrary *common.RemoteLibrary,
progress output.Progress,
resourceSchemaRepository *resource.SchemaRepository,

View File

@ -89,7 +89,7 @@ func TestScanGithubBranchProtection(t *testing.T) {
remoteLibrary.AddEnumerator(github.NewGithubBranchProtectionEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(githubres.GithubBranchProtectionResourceType, common.NewGenericDetailsFetcher(githubres.GithubBranchProtectionResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.err)
if err != nil {

View File

@ -85,7 +85,7 @@ func TestScanGithubMembership(t *testing.T) {
remoteLibrary.AddEnumerator(github.NewGithubMembershipEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(githubres.GithubMembershipResourceType, common.NewGenericDetailsFetcher(githubres.GithubMembershipResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.err)
if err != nil {

View File

@ -85,7 +85,7 @@ func TestScanGithubRepository(t *testing.T) {
remoteLibrary.AddEnumerator(github.NewGithubRepositoryEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(githubres.GithubRepositoryResourceType, common.NewGenericDetailsFetcher(githubres.GithubRepositoryResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.err)
if err != nil {

View File

@ -85,7 +85,7 @@ func TestScanGithubTeamMembership(t *testing.T) {
remoteLibrary.AddEnumerator(github.NewGithubTeamMembershipEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(githubres.GithubTeamMembershipResourceType, common.NewGenericDetailsFetcher(githubres.GithubTeamMembershipResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.err)
if err != nil {

View File

@ -86,7 +86,7 @@ func TestScanGithubTeam(t *testing.T) {
remoteLibrary.AddEnumerator(github.NewGithubTeamEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(githubres.GithubTeamResourceType, common.NewGenericDetailsFetcher(githubres.GithubTeamResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.err)
if err != nil {

View File

@ -110,7 +110,7 @@ func TestIamUser(t *testing.T) {
remoteLibrary.AddEnumerator(remoteaws.NewIamUserEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamUserResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamUserResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -238,7 +238,7 @@ func TestIamUserPolicy(t *testing.T) {
remoteLibrary.AddEnumerator(remoteaws.NewIamUserPolicyEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamUserPolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamUserPolicyResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -337,7 +337,7 @@ func TestIamPolicy(t *testing.T) {
remoteLibrary.AddEnumerator(remoteaws.NewIamPolicyEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamPolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamPolicyResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -452,7 +452,7 @@ func TestIamRole(t *testing.T) {
remoteLibrary.AddEnumerator(remoteaws.NewIamRoleEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamRoleResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamRoleResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -624,7 +624,7 @@ func TestIamRolePolicyAttachment(t *testing.T) {
remoteLibrary.AddEnumerator(remoteaws.NewIamRolePolicyAttachmentEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamRolePolicyAttachmentResourceType, remoteaws.NewIamRolePolicyAttachmentDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, c.err, err)
if err != nil {
@ -751,7 +751,7 @@ func TestIamAccessKey(t *testing.T) {
remoteLibrary.AddEnumerator(remoteaws.NewIamAccessKeyEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamAccessKeyResourceType, remoteaws.NewIamAccessKeyDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, c.wantErr, err)
if err != nil {
@ -953,7 +953,7 @@ func TestIamUserPolicyAttachment(t *testing.T) {
remoteLibrary.AddEnumerator(remoteaws.NewIamUserPolicyAttachmentEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamUserPolicyAttachmentResourceType, remoteaws.NewIamUserPolicyAttachmentDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, c.wantErr, err)
if err != nil {
@ -1073,7 +1073,7 @@ func TestIamRolePolicy(t *testing.T) {
remoteLibrary.AddEnumerator(remoteaws.NewIamRolePolicyEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsIamRolePolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsIamRolePolicyResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {

View File

@ -102,7 +102,7 @@ func TestKMSKey(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewKMSKeyEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsKmsKeyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsKmsKeyResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -192,7 +192,7 @@ func TestKMSAlias(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewKMSAliasEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsKmsAliasResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsKmsAliasResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {

View File

@ -123,7 +123,7 @@ func TestScanLambdaFunction(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewLambdaFunctionEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsLambdaFunctionResourceType, aws.NewLambdaFunctionDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, c.err, err)
if err != nil {
@ -232,7 +232,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewLambdaEventSourceMappingEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsLambdaEventSourceMappingResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsLambdaEventSourceMappingResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, c.err, err)
if err != nil {

View File

@ -110,7 +110,7 @@ func TestRDSDBInstance(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewRDSDBInstanceEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsDbInstanceResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDbInstanceResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -199,7 +199,7 @@ func TestRDSDBSubnetGroup(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewRDSDBSubnetGroupEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsDbSubnetGroupResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsDbSubnetGroupResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {

View File

@ -27,7 +27,6 @@ func IsSupported(remote string) bool {
func Activate(remote, version string, alerter *alerter.Alerter,
providerLibrary *terraform.ProviderLibrary,
supplierLibrary *resource.SupplierLibrary,
remoteLibrary *common.RemoteLibrary,
progress output.Progress,
resourceSchemaRepository *resource.SchemaRepository,
@ -35,9 +34,9 @@ func Activate(remote, version string, alerter *alerter.Alerter,
configDir string) error {
switch remote {
case aws.RemoteAWSTerraform:
return aws.Init(version, alerter, providerLibrary, supplierLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir)
return aws.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir)
case github.RemoteGithubTerraform:
return github.Init(version, alerter, providerLibrary, supplierLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir)
return github.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir)
default:
return errors.Errorf("unsupported remote '%s'", remote)
}

View File

@ -106,7 +106,7 @@ func TestRoute53_HealthCheck(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewRoute53HealthCheckEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsRoute53HealthCheckResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRoute53HealthCheckResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, c.err, err)
if err != nil {
@ -233,7 +233,7 @@ func TestRoute53_Zone(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewRoute53ZoneEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsRoute53ZoneResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRoute53ZoneResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, c.err, err)
if err != nil {
@ -434,7 +434,7 @@ func TestRoute53_Record(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewRoute53RecordEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsRoute53RecordResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsRoute53RecordResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, c.err, err)
if err != nil {

View File

@ -127,7 +127,7 @@ func TestS3Bucket(t *testing.T) {
}))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketResourceType, aws.NewS3BucketDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -277,7 +277,7 @@ func TestS3BucketInventory(t *testing.T) {
}))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketInventoryResourceType, aws.NewS3BucketInventoryDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -453,7 +453,7 @@ func TestS3BucketNotification(t *testing.T) {
}))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketNotificationResourceType, aws.NewS3BucketNotificationDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -605,7 +605,7 @@ func TestS3BucketMetrics(t *testing.T) {
}))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketMetricResourceType, aws.NewS3BucketMetricsDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -756,7 +756,7 @@ func TestS3BucketPolicy(t *testing.T) {
}))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketPolicyResourceType, aws.NewS3BucketPolicyDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -910,7 +910,7 @@ func TestS3BucketAnalytic(t *testing.T) {
}))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsS3BucketAnalyticsConfigurationResourceType, aws.NewS3BucketAnalyticDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, c.wantErr, err)
if err != nil {

View File

@ -16,7 +16,6 @@ type ScannerOptions struct {
}
type Scanner struct {
resourceSuppliers []resource.Supplier
enumeratorRunner *parallel.ParallelRunner
detailsFetcherRunner *parallel.ParallelRunner
remoteLibrary *common.RemoteLibrary
@ -24,9 +23,8 @@ type Scanner struct {
options ScannerOptions
}
func NewScanner(resourceSuppliers []resource.Supplier, remoteLibrary *common.RemoteLibrary, alerter alerter.AlerterInterface, options ScannerOptions) *Scanner {
func NewScanner(remoteLibrary *common.RemoteLibrary, alerter alerter.AlerterInterface, options ScannerOptions) *Scanner {
return &Scanner{
resourceSuppliers: resourceSuppliers,
enumeratorRunner: parallel.NewParallelRunner(context.TODO(), 10),
detailsFetcherRunner: parallel.NewParallelRunner(context.TODO(), 10),
remoteLibrary: remoteLibrary,
@ -57,31 +55,6 @@ loop:
return results, runner.Err()
}
func (s *Scanner) legacyScan() ([]resource.Resource, error) {
for _, resourceProvider := range s.resourceSuppliers {
supplier := resourceProvider
s.enumeratorRunner.Run(func() (interface{}, error) {
res, err := supplier.Resources()
if err != nil {
err := HandleResourceEnumerationError(err, s.alerter)
if err == nil {
return []resource.Resource{}, nil
}
return nil, err
}
for _, resource := range res {
logrus.WithFields(logrus.Fields{
"id": resource.TerraformId(),
"type": resource.TerraformType(),
}).Debug("[DEPRECATED] Found cloud resource")
}
return res, nil
})
}
return s.retrieveRunnerResults(s.enumeratorRunner)
}
func (s *Scanner) scan() ([]resource.Resource, error) {
for _, enumerator := range s.remoteLibrary.Enumerators() {
enumerator := enumerator
@ -135,20 +108,10 @@ func (s *Scanner) scan() ([]resource.Resource, error) {
}
func (s *Scanner) Resources() ([]resource.Resource, error) {
resources, err := s.legacyScan()
resources, err := s.scan()
if err != nil {
return nil, err
}
s.enumeratorRunner = parallel.NewParallelRunner(context.TODO(), 10)
enumerationResult, err := s.scan()
if err != nil {
return nil, err
}
resources = append(resources, enumerationResult...)
return resources, err
}

View File

@ -109,7 +109,7 @@ func TestScanSNSTopic(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewSNSTopicEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicResourceType, aws.NewSNSTopicDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, c.err, err)
if err != nil {
@ -202,7 +202,7 @@ func TestSNSTopicPolicyScan(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewSNSTopicPolicyEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicPolicyResourceType, aws.NewSNSTopicPolicyDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, c.err, err)
if err != nil {
@ -322,7 +322,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewSNSTopicSubscriptionEnumerator(repo, factory, alerter))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsSnsTopicSubscriptionResourceType, aws.NewSNSTopicSubscriptionDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.err)
if err != nil {

View File

@ -103,7 +103,7 @@ func TestSQSQueue(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewSQSQueueEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsSqsQueueResourceType, aws.NewSQSQueueDetailsFetcher(provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {
@ -223,7 +223,7 @@ func TestSQSQueuePolicy(t *testing.T) {
remoteLibrary.AddEnumerator(aws.NewSQSQueuePolicyEnumerator(repo, factory))
remoteLibrary.AddDetailsFetcher(resourceaws.AwsSqsQueuePolicyResourceType, common.NewGenericDetailsFetcher(resourceaws.AwsSqsQueuePolicyResourceType, provider, deserializer))
s := NewScanner(nil, remoteLibrary, alerter, scanOptions)
s := NewScanner(remoteLibrary, alerter, scanOptions)
got, err := s.Resources()
assert.Equal(tt, err, c.wantErr)
if err != nil {

View File

@ -1,19 +0,0 @@
package resource
type SupplierLibrary struct {
resourceSupplier []Supplier
}
func NewSupplierLibrary() *SupplierLibrary {
return &SupplierLibrary{
make([]Supplier, 0),
}
}
func (r *SupplierLibrary) AddSupplier(supplier Supplier) {
r.resourceSupplier = append(r.resourceSupplier, supplier)
}
func (r *SupplierLibrary) Suppliers() []Supplier {
return r.resourceSupplier
}