From 58d3956414b4d36b5b60088291dc709020dd3ce4 Mon Sep 17 00:00:00 2001 From: Martin Guibert Date: Tue, 8 Jun 2021 15:23:37 +0200 Subject: [PATCH] remove old case to have only one alert/handler for wrong arn --- .../aws/sns_topic_subscription_supplier.go | 34 +++---------------- .../sns_topic_subscription_supplier_test.go | 2 +- 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/pkg/remote/aws/sns_topic_subscription_supplier.go b/pkg/remote/aws/sns_topic_subscription_supplier.go index 7a86cc03f..86b3c3284 100644 --- a/pkg/remote/aws/sns_topic_subscription_supplier.go +++ b/pkg/remote/aws/sns_topic_subscription_supplier.go @@ -20,20 +20,6 @@ import ( "github.com/cloudskiff/driftctl/pkg/terraform" ) -type pendingTopicAlert struct { - endpoint *string -} - -func (p *pendingTopicAlert) Message() string { - return fmt.Sprintf("%s with pending confirmation status for endpoint \"%s\" will be ignored", - aws.AwsSnsTopicSubscriptionResourceType, - awssdk.StringValue(p.endpoint)) -} - -func (p *pendingTopicAlert) ShouldIgnoreResource() bool { - return false -} - type wrongArnTopicAlert struct { arn string endpoint *string @@ -90,21 +76,11 @@ func (s *SNSTopicSubscriptionSupplier) Resources() ([]resource.Resource, error) func (s *SNSTopicSubscriptionSupplier) readTopicSubscription(subscription *sns.Subscription, alertr alerter.AlerterInterface) (cty.Value, error) { if subscription.SubscriptionArn != nil && !arn.IsARN(*subscription.SubscriptionArn) { - switch *subscription.SubscriptionArn { - case "PendingConfirmation": - alertr.SendAlert( - fmt.Sprintf("%s.%s", aws.AwsSnsTopicSubscriptionResourceType, *subscription.SubscriptionArn), - &pendingTopicAlert{subscription.Endpoint}, - ) - return cty.NilVal, nil - default: - alertr.SendAlert( - fmt.Sprintf("%s.%s", aws.AwsSnsTopicSubscriptionResourceType, *subscription.SubscriptionArn), - &wrongArnTopicAlert{*subscription.SubscriptionArn, subscription.Endpoint}, - ) - return cty.NilVal, nil - - } + alertr.SendAlert( + fmt.Sprintf("%s.%s", aws.AwsSnsTopicSubscriptionResourceType, *subscription.SubscriptionArn), + &wrongArnTopicAlert{*subscription.SubscriptionArn, subscription.Endpoint}, + ) + return cty.NilVal, nil } val, err := s.reader.ReadResource(terraform.ReadResourceArgs{ diff --git a/pkg/remote/aws/sns_topic_subscription_supplier_test.go b/pkg/remote/aws/sns_topic_subscription_supplier_test.go index f7573a48c..344fb3658 100644 --- a/pkg/remote/aws/sns_topic_subscription_supplier_test.go +++ b/pkg/remote/aws/sns_topic_subscription_supplier_test.go @@ -71,7 +71,7 @@ func TestSNSTopicSubscriptionSupplier_Resources(t *testing.T) { }, alerts: map[string][]alerter.Alert{ "aws_sns_topic_subscription.PendingConfirmation": []alerter.Alert{ - &pendingTopicAlert{aws.String("TEST")}, + &wrongArnTopicAlert{"PendingConfirmation", aws.String("TEST")}, }, "aws_sns_topic_subscription.Incorrect": []alerter.Alert{ &wrongArnTopicAlert{"Incorrect", aws.String("INCORRECT")},