cloudposse-archives / tfmask

Terraform utility to mask select output from `terraform plan` and `terraform apply`
https://cloudposse.com/accelerate
Apache License 2.0
202 stars 27 forks source link

Regex Update for New Resources in Terraform 0.12 #15

Open bgreg1012 opened 4 years ago

bgreg1012 commented 4 years ago

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.

osterman commented 4 years ago

@eversC just a heads up ☝️ any suggestions?

eversC commented 4 years ago

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
bgreg1012 commented 4 years ago

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```
eversC commented 4 years ago

@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

osterman commented 4 years ago

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

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

osterman commented 4 years ago

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.

ricoli commented 4 years ago

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