Repository: chanzuckerberg/fogg
Pull request #479 (2020-05-27 18:38:07)

[fix] set REFRESH on check-plan
Fix bug where we were not respecting our refresh caching logic when
running check-plan. Because we didn't set this properly, we would
sometimes double-refresh, the first one via running teraform refresh in
the refresh target and a second as part of the terraform plan run.

### Test Plan
* CI
* tested manually via hacking the makefile in a repo

### References

codecov-commenter: # [Codecov](https://codecov.io/gh/chanzuckerberg/fogg/pull/479?src=pr&el=h1) Report
> Merging [#479](https://codecov.io/gh/chanzuckerberg/fogg/pull/479?src=pr&el=desc) into [master](https://codecov.io/gh/chanzuckerberg/fogg/commit/c67f4129a3f1d23d19c7ce38c2049e516d44aebd&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/chanzuckerberg/fogg/pull/479/graphs/tree.svg?width=650&height=150&src=pr&token=57DhtZ7g2A)](https://codecov.io/gh/chanzuckerberg/fogg/pull/479?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master     #479   +/-   ##
=======================================
  Coverage   59.36%   59.36%           
=======================================
  Files          19       19           
  Lines        1996     1996           
=======================================
  Hits         1185     1185           
  Misses        653      653           
  Partials      158      158           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/chanzuckerberg/fogg/pull/479?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/chanzuckerberg/fogg/pull/479?src=pr&el=footer). Last update [c67f412...cb6ebcb](https://codecov.io/gh/chanzuckerberg/fogg/pull/479?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/templates/repo/scripts/component.mk b/templates/repo/scripts/component.mk
index 99aa7b71..2eb92973 100644
--- a/templates/repo/scripts/component.mk
+++ b/templates/repo/scripts/component.mk
@@ -110,7 +110,7 @@ init: terraform check-auth ## run terraform init for this component
 
 check-plan: check-auth init refresh-cached ## run a terraform plan and check that it does not fail
 	@if [ "$(TF_BACKEND_KIND)" != "remote" ]; then \
-		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -out=$(CHECK_PLANFILE_PATH) ; \
+		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -refresh=$(REFRESH) -out=$(CHECK_PLANFILE_PATH) ; \
 		ERR=$$?; \
 		if [ -n "$(BUILDEVENT_FILE)" ]; then \
 			fogg exp entropy -f $(CHECK_PLANFILE_PATH) -o $(BUILDEVENT_FILE) ; \


Test patch:
diff --git a/testdata/bless_provider_yaml/scripts/component.mk b/testdata/bless_provider_yaml/scripts/component.mk
index 99aa7b71..2eb92973 100644
--- a/testdata/bless_provider_yaml/scripts/component.mk
+++ b/testdata/bless_provider_yaml/scripts/component.mk
@@ -110,7 +110,7 @@ init: terraform check-auth ## run terraform init for this component
 
 check-plan: check-auth init refresh-cached ## run a terraform plan and check that it does not fail
 	@if [ "$(TF_BACKEND_KIND)" != "remote" ]; then \
-		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -out=$(CHECK_PLANFILE_PATH) ; \
+		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -refresh=$(REFRESH) -out=$(CHECK_PLANFILE_PATH) ; \
 		ERR=$$?; \
 		if [ -n "$(BUILDEVENT_FILE)" ]; then \
 			fogg exp entropy -f $(CHECK_PLANFILE_PATH) -o $(BUILDEVENT_FILE) ; \
diff --git a/testdata/circleci/scripts/component.mk b/testdata/circleci/scripts/component.mk
index 99aa7b71..2eb92973 100644
--- a/testdata/circleci/scripts/component.mk
+++ b/testdata/circleci/scripts/component.mk
@@ -110,7 +110,7 @@ init: terraform check-auth ## run terraform init for this component
 
 check-plan: check-auth init refresh-cached ## run a terraform plan and check that it does not fail
 	@if [ "$(TF_BACKEND_KIND)" != "remote" ]; then \
-		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -out=$(CHECK_PLANFILE_PATH) ; \
+		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -refresh=$(REFRESH) -out=$(CHECK_PLANFILE_PATH) ; \
 		ERR=$$?; \
 		if [ -n "$(BUILDEVENT_FILE)" ]; then \
 			fogg exp entropy -f $(CHECK_PLANFILE_PATH) -o $(BUILDEVENT_FILE) ; \
diff --git a/testdata/github_actions/scripts/component.mk b/testdata/github_actions/scripts/component.mk
index 99aa7b71..2eb92973 100644
--- a/testdata/github_actions/scripts/component.mk
+++ b/testdata/github_actions/scripts/component.mk
@@ -110,7 +110,7 @@ init: terraform check-auth ## run terraform init for this component
 
 check-plan: check-auth init refresh-cached ## run a terraform plan and check that it does not fail
 	@if [ "$(TF_BACKEND_KIND)" != "remote" ]; then \
-		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -out=$(CHECK_PLANFILE_PATH) ; \
+		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -refresh=$(REFRESH) -out=$(CHECK_PLANFILE_PATH) ; \
 		ERR=$$?; \
 		if [ -n "$(BUILDEVENT_FILE)" ]; then \
 			fogg exp entropy -f $(CHECK_PLANFILE_PATH) -o $(BUILDEVENT_FILE) ; \
diff --git a/testdata/github_provider_yaml/scripts/component.mk b/testdata/github_provider_yaml/scripts/component.mk
index 99aa7b71..2eb92973 100644
--- a/testdata/github_provider_yaml/scripts/component.mk
+++ b/testdata/github_provider_yaml/scripts/component.mk
@@ -110,7 +110,7 @@ init: terraform check-auth ## run terraform init for this component
 
 check-plan: check-auth init refresh-cached ## run a terraform plan and check that it does not fail
 	@if [ "$(TF_BACKEND_KIND)" != "remote" ]; then \
-		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -out=$(CHECK_PLANFILE_PATH) ; \
+		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -refresh=$(REFRESH) -out=$(CHECK_PLANFILE_PATH) ; \
 		ERR=$$?; \
 		if [ -n "$(BUILDEVENT_FILE)" ]; then \
 			fogg exp entropy -f $(CHECK_PLANFILE_PATH) -o $(BUILDEVENT_FILE) ; \
diff --git a/testdata/okta_provider_yaml/scripts/component.mk b/testdata/okta_provider_yaml/scripts/component.mk
index 99aa7b71..2eb92973 100644
--- a/testdata/okta_provider_yaml/scripts/component.mk
+++ b/testdata/okta_provider_yaml/scripts/component.mk
@@ -110,7 +110,7 @@ init: terraform check-auth ## run terraform init for this component
 
 check-plan: check-auth init refresh-cached ## run a terraform plan and check that it does not fail
 	@if [ "$(TF_BACKEND_KIND)" != "remote" ]; then \
-		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -out=$(CHECK_PLANFILE_PATH) ; \
+		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -refresh=$(REFRESH) -out=$(CHECK_PLANFILE_PATH) ; \
 		ERR=$$?; \
 		if [ -n "$(BUILDEVENT_FILE)" ]; then \
 			fogg exp entropy -f $(CHECK_PLANFILE_PATH) -o $(BUILDEVENT_FILE) ; \
diff --git a/testdata/snowflake_provider_yaml/scripts/component.mk b/testdata/snowflake_provider_yaml/scripts/component.mk
index 99aa7b71..2eb92973 100644
--- a/testdata/snowflake_provider_yaml/scripts/component.mk
+++ b/testdata/snowflake_provider_yaml/scripts/component.mk
@@ -110,7 +110,7 @@ init: terraform check-auth ## run terraform init for this component
 
 check-plan: check-auth init refresh-cached ## run a terraform plan and check that it does not fail
 	@if [ "$(TF_BACKEND_KIND)" != "remote" ]; then \
-		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -out=$(CHECK_PLANFILE_PATH) ; \
+		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -refresh=$(REFRESH) -out=$(CHECK_PLANFILE_PATH) ; \
 		ERR=$$?; \
 		if [ -n "$(BUILDEVENT_FILE)" ]; then \
 			fogg exp entropy -f $(CHECK_PLANFILE_PATH) -o $(BUILDEVENT_FILE) ; \
diff --git a/testdata/tfe_provider_yaml/scripts/component.mk b/testdata/tfe_provider_yaml/scripts/component.mk
index 99aa7b71..2eb92973 100644
--- a/testdata/tfe_provider_yaml/scripts/component.mk
+++ b/testdata/tfe_provider_yaml/scripts/component.mk
@@ -110,7 +110,7 @@ init: terraform check-auth ## run terraform init for this component
 
 check-plan: check-auth init refresh-cached ## run a terraform plan and check that it does not fail
 	@if [ "$(TF_BACKEND_KIND)" != "remote" ]; then \
-		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -out=$(CHECK_PLANFILE_PATH) ; \
+		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -refresh=$(REFRESH) -out=$(CHECK_PLANFILE_PATH) ; \
 		ERR=$$?; \
 		if [ -n "$(BUILDEVENT_FILE)" ]; then \
 			fogg exp entropy -f $(CHECK_PLANFILE_PATH) -o $(BUILDEVENT_FILE) ; \
diff --git a/testdata/v2_full_yaml/scripts/component.mk b/testdata/v2_full_yaml/scripts/component.mk
index 99aa7b71..2eb92973 100644
--- a/testdata/v2_full_yaml/scripts/component.mk
+++ b/testdata/v2_full_yaml/scripts/component.mk
@@ -110,7 +110,7 @@ init: terraform check-auth ## run terraform init for this component
 
 check-plan: check-auth init refresh-cached ## run a terraform plan and check that it does not fail
 	@if [ "$(TF_BACKEND_KIND)" != "remote" ]; then \
-		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -out=$(CHECK_PLANFILE_PATH) ; \
+		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -refresh=$(REFRESH) -out=$(CHECK_PLANFILE_PATH) ; \
 		ERR=$$?; \
 		if [ -n "$(BUILDEVENT_FILE)" ]; then \
 			fogg exp entropy -f $(CHECK_PLANFILE_PATH) -o $(BUILDEVENT_FILE) ; \
diff --git a/testdata/v2_minimal_valid_yaml/scripts/component.mk b/testdata/v2_minimal_valid_yaml/scripts/component.mk
index 99aa7b71..2eb92973 100644
--- a/testdata/v2_minimal_valid_yaml/scripts/component.mk
+++ b/testdata/v2_minimal_valid_yaml/scripts/component.mk
@@ -110,7 +110,7 @@ init: terraform check-auth ## run terraform init for this component
 
 check-plan: check-auth init refresh-cached ## run a terraform plan and check that it does not fail
 	@if [ "$(TF_BACKEND_KIND)" != "remote" ]; then \
-		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -out=$(CHECK_PLANFILE_PATH) ; \
+		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -refresh=$(REFRESH) -out=$(CHECK_PLANFILE_PATH) ; \
 		ERR=$$?; \
 		if [ -n "$(BUILDEVENT_FILE)" ]; then \
 			fogg exp entropy -f $(CHECK_PLANFILE_PATH) -o $(BUILDEVENT_FILE) ; \
diff --git a/testdata/v2_no_aws_provider_yaml/scripts/component.mk b/testdata/v2_no_aws_provider_yaml/scripts/component.mk
index 99aa7b71..2eb92973 100644
--- a/testdata/v2_no_aws_provider_yaml/scripts/component.mk
+++ b/testdata/v2_no_aws_provider_yaml/scripts/component.mk
@@ -110,7 +110,7 @@ init: terraform check-auth ## run terraform init for this component
 
 check-plan: check-auth init refresh-cached ## run a terraform plan and check that it does not fail
 	@if [ "$(TF_BACKEND_KIND)" != "remote" ]; then \
-		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -out=$(CHECK_PLANFILE_PATH) ; \
+		$(terraform_command) plan $(TF_ARGS) -detailed-exitcode -lock=false -refresh=$(REFRESH) -out=$(CHECK_PLANFILE_PATH) ; \
 		ERR=$$?; \
 		if [ -n "$(BUILDEVENT_FILE)" ]; then \
 			fogg exp entropy -f $(CHECK_PLANFILE_PATH) -o $(BUILDEVENT_FILE) ; \