From b1894b2ac84c34f3f7adc19bb1c9f0a63430340a Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Thu, 8 Nov 2018 12:33:58 -0500 Subject: [PATCH] gosimple: Fix WAF-related issues --- aws/resource_aws_waf_byte_match_set.go | 2 +- aws/resource_aws_waf_rule_group.go | 5 +---- aws/resource_aws_waf_size_constraint_set_test.go | 6 ++---- aws/resource_aws_waf_sql_injection_match_set.go | 2 +- aws/resource_aws_waf_xss_match_set.go | 2 +- aws/resource_aws_wafregional_ipset.go | 2 +- aws/resource_aws_wafregional_rule.go | 2 +- aws/resource_aws_wafregional_rule_group.go | 5 +---- aws/resource_aws_wafregional_size_constraint_set_test.go | 6 ++---- aws/resource_aws_wafregional_web_acl_association.go | 6 +----- aws/waf_helpers.go | 8 ++++---- 11 files changed, 16 insertions(+), 30 deletions(-) diff --git a/aws/resource_aws_waf_byte_match_set.go b/aws/resource_aws_waf_byte_match_set.go index 3399f45f1b0..9c62800d601 100644 --- a/aws/resource_aws_waf_byte_match_set.go +++ b/aws/resource_aws_waf_byte_match_set.go @@ -175,7 +175,7 @@ func updateByteMatchSetResource(id string, oldT, newT []interface{}, conn *waf.W } func flattenWafByteMatchTuples(bmt []*waf.ByteMatchTuple) []interface{} { - out := make([]interface{}, len(bmt), len(bmt)) + out := make([]interface{}, len(bmt)) for i, t := range bmt { m := make(map[string]interface{}) diff --git a/aws/resource_aws_waf_rule_group.go b/aws/resource_aws_waf_rule_group.go index 42fb960deda..803d6ea07a8 100644 --- a/aws/resource_aws_waf_rule_group.go +++ b/aws/resource_aws_waf_rule_group.go @@ -140,11 +140,8 @@ func resourceAwsWafRuleGroupDelete(d *schema.ResourceData, meta interface{}) err oldRules := d.Get("activated_rule").(*schema.Set).List() err := deleteWafRuleGroup(d.Id(), oldRules, conn) - if err != nil { - return err - } - return nil + return err } func deleteWafRuleGroup(id string, oldRules []interface{}, conn *waf.WAF) error { diff --git a/aws/resource_aws_waf_size_constraint_set_test.go b/aws/resource_aws_waf_size_constraint_set_test.go index ba9d72bc2b0..c65ccd06e2a 100644 --- a/aws/resource_aws_waf_size_constraint_set_test.go +++ b/aws/resource_aws_waf_size_constraint_set_test.go @@ -219,10 +219,8 @@ func testAccCheckAWSWafSizeConstraintSetDisappears(v *waf.SizeConstraintSet) res } return conn.DeleteSizeConstraintSet(opts) }) - if err != nil { - return err - } - return nil + + return err } } diff --git a/aws/resource_aws_waf_sql_injection_match_set.go b/aws/resource_aws_waf_sql_injection_match_set.go index 42c6458ccc9..ff9bb4d6eb4 100644 --- a/aws/resource_aws_waf_sql_injection_match_set.go +++ b/aws/resource_aws_waf_sql_injection_match_set.go @@ -168,7 +168,7 @@ func updateSqlInjectionMatchSetResource(id string, oldT, newT []interface{}, con } func flattenWafSqlInjectionMatchTuples(ts []*waf.SqlInjectionMatchTuple) []interface{} { - out := make([]interface{}, len(ts), len(ts)) + out := make([]interface{}, len(ts)) for i, t := range ts { m := make(map[string]interface{}) m["text_transformation"] = *t.TextTransformation diff --git a/aws/resource_aws_waf_xss_match_set.go b/aws/resource_aws_waf_xss_match_set.go index 7ecef45f6c4..56dff11917f 100644 --- a/aws/resource_aws_waf_xss_match_set.go +++ b/aws/resource_aws_waf_xss_match_set.go @@ -168,7 +168,7 @@ func updateXssMatchSetResource(id string, oldT, newT []interface{}, conn *waf.WA } func flattenWafXssMatchTuples(ts []*waf.XssMatchTuple) []interface{} { - out := make([]interface{}, len(ts), len(ts)) + out := make([]interface{}, len(ts)) for i, t := range ts { m := make(map[string]interface{}) m["field_to_match"] = flattenFieldToMatch(t.FieldToMatch) diff --git a/aws/resource_aws_wafregional_ipset.go b/aws/resource_aws_wafregional_ipset.go index 3ef2f56c101..b5cd3828f95 100644 --- a/aws/resource_aws_wafregional_ipset.go +++ b/aws/resource_aws_wafregional_ipset.go @@ -103,7 +103,7 @@ func resourceAwsWafRegionalIPSetRead(d *schema.ResourceData, meta interface{}) e } func flattenWafIpSetDescriptorWR(in []*waf.IPSetDescriptor) []interface{} { - descriptors := make([]interface{}, len(in), len(in)) + descriptors := make([]interface{}, len(in)) for i, descriptor := range in { d := map[string]interface{}{ diff --git a/aws/resource_aws_wafregional_rule.go b/aws/resource_aws_wafregional_rule.go index f478a94824c..25cc935a869 100644 --- a/aws/resource_aws_wafregional_rule.go +++ b/aws/resource_aws_wafregional_rule.go @@ -168,7 +168,7 @@ func updateWafRegionalRuleResource(id string, oldP, newP []interface{}, meta int } func flattenWafPredicates(ts []*waf.Predicate) []interface{} { - out := make([]interface{}, len(ts), len(ts)) + out := make([]interface{}, len(ts)) for i, p := range ts { m := make(map[string]interface{}) m["negated"] = *p.Negated diff --git a/aws/resource_aws_wafregional_rule_group.go b/aws/resource_aws_wafregional_rule_group.go index 3af7db109f4..e82e09798fc 100644 --- a/aws/resource_aws_wafregional_rule_group.go +++ b/aws/resource_aws_wafregional_rule_group.go @@ -144,11 +144,8 @@ func resourceAwsWafRegionalRuleGroupDelete(d *schema.ResourceData, meta interfac oldRules := d.Get("activated_rule").(*schema.Set).List() err := deleteWafRegionalRuleGroup(d.Id(), oldRules, conn, region) - if err != nil { - return err - } - return nil + return err } func deleteWafRegionalRuleGroup(id string, oldRules []interface{}, conn *wafregional.WAFRegional, region string) error { diff --git a/aws/resource_aws_wafregional_size_constraint_set_test.go b/aws/resource_aws_wafregional_size_constraint_set_test.go index c364f846665..09da9119492 100644 --- a/aws/resource_aws_wafregional_size_constraint_set_test.go +++ b/aws/resource_aws_wafregional_size_constraint_set_test.go @@ -220,10 +220,8 @@ func testAccCheckAWSWafRegionalSizeConstraintSetDisappears(constraints *waf.Size } return conn.DeleteSizeConstraintSet(opts) }) - if err != nil { - return err - } - return nil + + return err } } diff --git a/aws/resource_aws_wafregional_web_acl_association.go b/aws/resource_aws_wafregional_web_acl_association.go index f076daebcb8..eb3a9128a22 100644 --- a/aws/resource_aws_wafregional_web_acl_association.go +++ b/aws/resource_aws_wafregional_web_acl_association.go @@ -113,11 +113,7 @@ func resourceAwsWafRegionalWebAclAssociationDelete(d *schema.ResourceData, meta // If action successful HTTP 200 response with an empty body _, err := conn.DisassociateWebACL(params) - if err != nil { - return err - } - - return nil + return err } func resourceAwsWafRegionalWebAclAssociationParseId(id string) (webAclId, resourceArn string) { diff --git a/aws/waf_helpers.go b/aws/waf_helpers.go index 52d7f0d0b2c..b9e6403ce3c 100644 --- a/aws/waf_helpers.go +++ b/aws/waf_helpers.go @@ -98,7 +98,7 @@ func diffWafSizeConstraints(oldS, newS []interface{}) []*waf.SizeConstraintSetUp } func flattenWafSizeConstraints(sc []*waf.SizeConstraint) []interface{} { - out := make([]interface{}, len(sc), len(sc)) + out := make([]interface{}, len(sc)) for i, c := range sc { m := make(map[string]interface{}) m["comparison_operator"] = *c.ComparisonOperator @@ -113,7 +113,7 @@ func flattenWafSizeConstraints(sc []*waf.SizeConstraint) []interface{} { } func flattenWafGeoMatchConstraint(ts []*waf.GeoMatchConstraint) []interface{} { - out := make([]interface{}, len(ts), len(ts)) + out := make([]interface{}, len(ts)) for i, t := range ts { m := make(map[string]interface{}) m["type"] = *t.Type @@ -256,7 +256,7 @@ func diffWafRuleGroupActivatedRules(oldRules, newRules []interface{}) []*waf.Rul } func flattenWafActivatedRules(activatedRules []*waf.ActivatedRule) []interface{} { - out := make([]interface{}, len(activatedRules), len(activatedRules)) + out := make([]interface{}, len(activatedRules)) for i, ar := range activatedRules { rule := map[string]interface{}{ "priority": int(*ar.Priority), @@ -292,7 +292,7 @@ func expandWafActivatedRule(rule map[string]interface{}) *waf.ActivatedRule { } func flattenWafRegexMatchTuples(tuples []*waf.RegexMatchTuple) []interface{} { - out := make([]interface{}, len(tuples), len(tuples)) + out := make([]interface{}, len(tuples)) for i, t := range tuples { m := make(map[string]interface{})