From 57989cc34611d2c9138787709cf8572a979e11f8 Mon Sep 17 00:00:00 2001 From: sundowndev Date: Tue, 14 Dec 2021 18:57:46 +0400 Subject: [PATCH] refactor: delete unused middleware --- pkg/middlewares/aws_nat_gateway_eip_assoc.go | 2 +- ..._storage_bucket_iam_binding_transformer.go | 55 ------------------- 2 files changed, 1 insertion(+), 56 deletions(-) delete mode 100644 pkg/middlewares/google_storage_bucket_iam_binding_transformer.go diff --git a/pkg/middlewares/aws_nat_gateway_eip_assoc.go b/pkg/middlewares/aws_nat_gateway_eip_assoc.go index 9a02cd03..8914b88a 100644 --- a/pkg/middlewares/aws_nat_gateway_eip_assoc.go +++ b/pkg/middlewares/aws_nat_gateway_eip_assoc.go @@ -16,7 +16,7 @@ func NewAwsNatGatewayEipAssoc() AwsNatGatewayEipAssoc { // It implies that driftctl read a aws_eip_association resource from remote // As we cannot use aws_eip_association in terraform to assign an eip to an aws_nat_gateway // we should remove this association to ensure we do not output noise in unmanaged resources -func (a AwsNatGatewayEipAssoc) Execute(remoteResources, resourcesFromState *[]*resource.Resource) error { +func (a AwsNatGatewayEipAssoc) Execute(remoteResources, _ *[]*resource.Resource) error { newRemoteResources := make([]*resource.Resource, 0, len(*remoteResources)) for _, remoteResource := range *remoteResources { diff --git a/pkg/middlewares/google_storage_bucket_iam_binding_transformer.go b/pkg/middlewares/google_storage_bucket_iam_binding_transformer.go deleted file mode 100644 index d97a90be..00000000 --- a/pkg/middlewares/google_storage_bucket_iam_binding_transformer.go +++ /dev/null @@ -1,55 +0,0 @@ -package middlewares - -import ( - "fmt" - - "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/google" -) - -// GoogleStorageBucketIAMBindingTransformer Transforms Bucket IAM binding in bucket iam member to ease comparison. -type GoogleStorageBucketIAMBindingTransformer struct { - resourceFactory resource.ResourceFactory -} - -func NewGoogleStorageBucketIAMBindingTransformer(resourceFactory resource.ResourceFactory) *GoogleStorageBucketIAMBindingTransformer { - return &GoogleStorageBucketIAMBindingTransformer{resourceFactory} -} - -func (m *GoogleStorageBucketIAMBindingTransformer) Execute(_, resourcesFromState *[]*resource.Resource) error { - - resources := make([]*resource.Resource, 0) - - for _, stateRes := range *resourcesFromState { - // Ignore all resources other than BucketIamBinding - if stateRes.ResourceType() != google.GoogleStorageBucketIamBindingResourceType { - resources = append(resources, stateRes) - continue - } - - bucket := *stateRes.Attrs.GetString("bucket") - roleName := *stateRes.Attrs.GetString("role") - members, _ := stateRes.Attrs.Get("members") - - for _, member := range members.([]interface{}) { - id := fmt.Sprintf("%s/%s/%s", bucket, roleName, member) - resources = append( - resources, - m.resourceFactory.CreateAbstractResource( - google.GoogleStorageBucketIamMemberResourceType, - id, - map[string]interface{}{ - "id": id, - "bucket": bucket, - "role": roleName, - "member": member.(string), - }, - ), - ) - } - } - - *resourcesFromState = resources - - return nil -}