tfmask icon indicating copy to clipboard operation
tfmask copied to clipboard

Regex Update for New Resources in Terraform 0.12

Open bgreg1012 opened this issue 5 years ago • 7 comments
trafficstars

Hi, I have a use-case in Terraform 0.12 where I'm adding new resources and I found that the reTfPlanLine regex wasn't capturing lines like: + token = "abC123ABc". To fix this I added another capture group in reTfPlanLine to match the scenario where -> ... may not exist, and the logic to handle the different size capture groups.

bgreg1012 avatar May 29 '20 19:05 bgreg1012

@eversC just a heads up ☝️ any suggestions?

osterman avatar May 29 '20 19:05 osterman

Taking a look

For now, though, the test seems to fail:

$ go test -v

=== RUN   TestProcessLine
--- FAIL: TestProcessLine (0.00s)
    main_test.go:73: Got       ~ result           = "************" ->  -> (known after apply) *known after apply), want       ~ result           = "************" -> (known after apply)
    main_test.go:73: Got  ~ id =               "**************************************************************************************" ->  -> (known after apply)*known after apply), want  ~ id =               "**************************************************************************************" -> (known after apply)
=== RUN   TestGetCurrentResource
--- PASS: TestGetCurrentResource (0.00s)
=== RUN   TestPlanStatus
--- PASS: TestPlanStatus (0.00s)
=== RUN   TestMaskValue
--- PASS: TestMaskValue (0.00s)
FAIL
exit status 1
FAIL	_/tfmask	0.415s

eversC avatar May 29 '20 22:05 eversC

Tests are failing? 🤔 When I run locally on that branch they pass:

=== RUN   TestProcessLine
--- PASS: TestProcessLine (0.00s)
=== RUN   TestGetCurrentResource
--- PASS: TestGetCurrentResource (0.00s)
=== RUN   TestPlanStatus
--- PASS: TestPlanStatus (0.00s)
=== RUN   TestMaskValue
--- PASS: TestMaskValue (0.00s)
PASS
ok  	github.com/bgreg1012/tfmask	0.030s```

bgreg1012 avatar May 29 '20 22:05 bgreg1012

@bgreg1012 you're right, I was running it on your master branch, which didn't have the 2nd commit 🤦

we should put this all in the makefile, but if you run

mkdir release
go build
mv tfmask release
cd tests
make test

I did a diff of the output of that on your branch, compared to cloudposse/tfmask, and it looks like values of the "random_id" resource are now revealed

eversC avatar May 29 '20 23:05 eversC

and it looks like values of the "random_id" resource are now revealed

@bgreg1012 were you able to take a look at this?

osterman avatar Jun 05 '20 23:06 osterman

I can confirm with @eversC there's a regression

image

Please note that running make -C tests test requires human spot-checking =/ not really good tests, just more like a sanity check.

osterman avatar Jul 01 '20 03:07 osterman

Hi @bgreg1012 , thanks for opening this - any chance you could look into the tests as mentioned by @osterman?

ricoli avatar Jul 10 '20 09:07 ricoli