Skip to content
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

Skip un-used variable block attributes #153

Merged
merged 1 commit into from
Mar 30, 2022
Merged

Skip un-used variable block attributes #153

merged 1 commit into from
Mar 30, 2022

Conversation

bendrucker
Copy link
Member

When calling helper.TestRunner, variable blocks with any attribute other than default will trigger a parsing error. The runner needs to read the default and other attributes should silently pass through. Currently, they cause a panic.

With the modified test:

--- FAIL: Test_EvaluateExpr (0.00s)
    --- FAIL: Test_EvaluateExpr/string_interpolation (0.00s)
panic: Failed to initialize runner: main.tf:3,2-6: Unsupported argument; An argument named "type" is not expected here. [recovered]
	panic: Failed to initialize runner: main.tf:3,2-6: Unsupported argument; An argument named "type" is not expected here.

goroutine 6 [running]:
testing.tRunner.func1.2({0x12fb300, 0xc000049e20})
	/usr/local/Cellar/go/1.18/libexec/src/testing/testing.go:1389 +0x24e
testing.tRunner.func1()
	/usr/local/Cellar/go/1.18/libexec/src/testing/testing.go:1392 +0x39f
panic({0x12fb300, 0xc000049e20})
	/usr/local/Cellar/go/1.18/libexec/src/runtime/panic.go:838 +0x207
github.com/terraform-linters/tflint-plugin-sdk/helper.TestRunner(0xc0001096c0, 0xc000067e20?)
	/Users/ben/src/terraform-linters/tflint-plugin-sdk/helper/testing.go:40 +0x394
github.com/terraform-linters/tflint-plugin-sdk/helper.Test_EvaluateExpr.func1(0xc0001096c0)
	/Users/ben/src/terraform-linters/tflint-plugin-sdk/helper/runner_test.go:281 +0x105
testing.tRunner(0xc0001096c0, 0xc000049d50)
	/usr/local/Cellar/go/1.18/libexec/src/testing/testing.go:1439 +0x102
created by testing.(*T).Run
	/usr/local/Cellar/go/1.18/libexec/src/testing/testing.go:1486 +0x35f
FAIL	github.com/terraform-linters/tflint-plugin-sdk/helper	0.137s
FAIL

Using PartialContent rather than Content resolves the failed test.

Closes #152

@bendrucker bendrucker merged commit c549c67 into master Mar 30, 2022
@bendrucker bendrucker deleted the variable-attrs branch March 30, 2022 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

An argument named "type" is not expected here
1 participant