refactor: delete unused middleware

main
sundowndev 2021-12-14 18:57:46 +04:00
parent c7b795e608
commit 57989cc346
No known key found for this signature in database
GPG Key ID: 100CE2799D978462
2 changed files with 1 additions and 56 deletions

View File

@ -16,7 +16,7 @@ func NewAwsNatGatewayEipAssoc() AwsNatGatewayEipAssoc {
// It implies that driftctl read a aws_eip_association resource from remote // 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 // 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 // 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)) newRemoteResources := make([]*resource.Resource, 0, len(*remoteResources))
for _, remoteResource := range *remoteResources { for _, remoteResource := range *remoteResources {

View File

@ -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
}