Skip to content

Commit

Permalink
Amend find functions; reduce conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
zhelding committed Aug 2, 2022
1 parent 4a2bb85 commit 6787fc1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions internal/service/waf/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (
)

func FindSubscribedRuleGroupByNameOrMetricName(ctx context.Context, conn *waf.WAF, name string, metricName string) (*waf.SubscribedRuleGroupSummary, error) {
if name == "" && metricName == "" {
return nil, errors.New("must specify either name or metricName")
}

hasName := name != ""
hasMetricName := metricName != ""
hasMatch := false

if !hasName && !hasMetricName {
return nil, errors.New("must specify either name or metricName")
}

input := &waf.ListSubscribedRuleGroupsInput{}

matchingRuleGroup := &waf.SubscribedRuleGroupSummary{}
Expand Down
8 changes: 4 additions & 4 deletions internal/service/wafregional/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ func FindRegexMatchSetByID(conn *wafregional.WAFRegional, id string) (*waf.Regex
}

func FindSubscribedRuleGroupByNameOrMetricName(ctx context.Context, conn *wafregional.WAFRegional, name string, metricName string) (*waf.SubscribedRuleGroupSummary, error) {
if name == "" && metricName == "" {
return nil, errors.New("must specify either name or metricName")
}

hasName := name != ""
hasMetricName := metricName != ""
hasMatch := false

if !hasName && !hasMetricName {
return nil, errors.New("must specify either name or metricName")
}

input := &waf.ListSubscribedRuleGroupsInput{}

matchingRuleGroup := &waf.SubscribedRuleGroupSummary{}
Expand Down

0 comments on commit 6787fc1

Please sign in to comment.