Skip to content

Call EnsureNoError after evaluating aws_route expression so unevaluable expressions are skipped #320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions rules/aws_route_not_specified_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ func (r *AwsRouteNotSpecifiedTargetRule) Check(runner tflint.Runner) error {
for _, attribute := range resource.Body.Attributes {
var val cty.Value
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
err = runner.EnsureNoError(err, func() error {
if val.IsNull() {
nullAttributes = nullAttributes + 1
}
return nil
})
if err != nil {
return err
}

if val.IsNull() {
nullAttributes = nullAttributes + 1
}
}

if len(resource.Body.Attributes)-nullAttributes == 0 {
Expand Down
9 changes: 6 additions & 3 deletions rules/aws_route_specified_multiple_targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,16 @@ func (r *AwsRouteSpecifiedMultipleTargetsRule) Check(runner tflint.Runner) error
for _, attribute := range resource.Body.Attributes {
var val cty.Value
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
err = runner.EnsureNoError(err, func() error {
if val.IsNull() {
nullAttributes = nullAttributes + 1
}
return nil
})
if err != nil {
return err
}

if val.IsNull() {
nullAttributes = nullAttributes + 1
}
}

if len(resource.Body.Attributes)-nullAttributes > 1 {
Expand Down