Merge pull request #1283 from snyk/refact/middlewares
Delete unused GoogleStorageBucketIAMBindingTransformer middlewaremain
commit
3bf7b565bf
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue