terraform/command/test-fixtures
Martin Atkins 86c02d5c35 command: "terraform init" can partially initialize for 0.12upgrade
There are a few constructs from 0.11 and prior that cause 0.12 parsing to
fail altogether, which previously created a chicken/egg problem because
we need to install the providers in order to run "terraform 0.12upgrade"
and thus fix the problem.

This changes "terraform init" to use the new "early configuration" loader
for module and provider installation. This is built on the more permissive
parser in the terraform-config-inspect package, and so it allows us to
read out the top-level blocks from the configuration while accepting
legacy HCL syntax.

In the long run this will let us do version compatibility detection before
attempting a "real" config load, giving us better error messages for any
future syntax additions, but in the short term the key thing is that it
allows us to install the dependencies even if the configuration isn't
fully valid.

Because backend init still requires full configuration, this introduces a
new mode of terraform init where it detects heuristically if it seems like
we need to do a configuration upgrade and does a partial init if so,
before finally directing the user to run "terraform 0.12upgrade" before
running any other commands.

The heuristic here is based on two assumptions:
- If the "early" loader finds no errors but the normal loader does, the
  configuration is likely to be valid for Terraform 0.11 but not 0.12.
- If there's already a version constraint in the configuration that
  excludes Terraform versions prior to v0.12 then the configuration is
  probably _already_ upgraded and so it's just a normal syntax error,
  even if the early loader didn't detect it.

Once the upgrade process is removed in 0.13.0 (users will be required to
go stepwise 0.11 -> 0.12 -> 0.13 to upgrade after that), some of this can
be simplified to remove that special mode, but the idea of doing the
dependency version checks against the liberal parser will remain valuable
to increase our chances of reporting version-based incompatibilities
rather than syntax errors as we add new features in future.
2019-01-14 11:33:21 -08:00
..
apply dos2unix 2014-07-28 10:43:00 -07:00
apply-config-invalid dos2unix 2014-07-28 10:43:00 -07:00
apply-destroy-targeted core: targeted operations 2015-03-31 14:49:38 -05:00
apply-error dos2unix 2014-07-28 10:43:00 -07:00
apply-input command: Update apply_test.go for new provider types 2018-10-16 19:14:11 -07:00
apply-input-partial command: Fix some tests for the "apply" command 2018-10-16 19:14:11 -07:00
apply-plan-no-module Add test to verify that Validation isn't called 2017-03-27 18:39:18 -04:00
apply-sensitive-output core: Add support for marking outputs as sensitive (#6559) 2016-05-09 15:46:07 -04:00
apply-shutdown dos2unix 2014-07-28 10:43:00 -07:00
apply-terraform-env command: Fix some tests for the "apply" command 2018-10-16 19:14:11 -07:00
apply-vars dos2unix 2014-07-28 10:43:00 -07:00
backend-change command: Fix various TestMetaBackend-prefix tests 2018-11-19 09:02:35 -08:00
backend-change-multi-default-to-single command: Fix various TestMetaBackend-prefix tests 2018-11-19 09:02:35 -08:00
backend-change-multi-to-multi command: Fix various TestMetaBackend-prefix tests 2018-11-19 09:02:35 -08:00
backend-change-multi-to-no-default-with-default command: Fix various TestMetaBackend-prefix tests 2018-11-19 09:02:35 -08:00
backend-change-multi-to-no-default-without-default command: Fix various TestMetaBackend-prefix tests 2018-11-19 09:02:35 -08:00
backend-change-multi-to-single command: Fix various TestMetaBackend-prefix tests 2018-11-19 09:02:35 -08:00
backend-change-single-to-single command: Fix various TestMetaBackend-prefix tests 2018-11-19 09:02:35 -08:00
backend-changed-with-legacy command: convert to use backends 2017-01-26 14:33:49 -08:00
backend-inmem-locked Add complete unlock test 2017-02-20 14:50:31 -05:00
backend-new command: convert to use backends 2017-01-26 14:33:49 -08:00
backend-new-interp command: validate backend config 2017-03-02 14:07:49 -08:00
backend-new-legacy command: remove legacy remote state on migration 2017-03-20 10:14:59 -07:00
backend-new-migrate command: Fix TestMetaBackend_configureNewWithState 2018-11-19 09:02:35 -08:00
backend-new-migrate-existing command: Fix various TestMetaBackend-prefix tests 2018-11-19 09:02:35 -08:00
backend-plan-backend-empty command: convert to use backends 2017-01-26 14:33:49 -08:00
backend-plan-backend-empty-config command: convert to use backends 2017-01-26 14:33:49 -08:00
backend-plan-backend-match command: convert to use backends 2017-01-26 14:33:49 -08:00
backend-plan-backend-mismatch command: convert to use backends 2017-01-26 14:33:49 -08:00
backend-plan-legacy command: convert to use backends 2017-01-26 14:33:49 -08:00
backend-plan-legacy-data command: convert to use backends 2017-01-26 14:33:49 -08:00
backend-plan-local command: convert to use backends 2017-01-26 14:33:49 -08:00
backend-plan-local-match command: convert to use backends 2017-01-26 14:33:49 -08:00
backend-plan-local-mismatch-lineage command: convert to use backends 2017-01-26 14:33:49 -08:00
backend-plan-local-newer command: convert to use backends 2017-01-26 14:33:49 -08:00
backend-unchanged command: Update backend-unchanged fixture for new expectations 2018-10-16 19:14:11 -07:00
backend-unchanged-with-legacy command: convert to use backends 2017-01-26 14:33:49 -08:00
backend-unset command: Fix various TestMetaBackend-prefix tests 2018-11-19 09:02:35 -08:00
backend-unset-with-legacy command: convert to use backends 2017-01-26 14:33:49 -08:00
empty command: show a special error message when importing in an empty dir 2017-12-11 16:08:33 -08:00
get tests: remove unnecessary symlink 2015-08-31 15:45:43 -05:00
graph dos2unix 2014-07-28 10:43:00 -07:00
import-missing-resource-config command: validate import resource address early 2017-06-09 14:03:59 -07:00
import-provider command: require resource to be in config before import 2017-06-09 14:03:59 -07:00
import-provider-aliased command: require resource to be in config before import 2017-06-09 14:03:59 -07:00
import-provider-implicit core: provide config to all import context tests 2017-06-09 14:03:59 -07:00
import-provider-remote-state Don't ForceLocal for the import backend 2017-08-09 10:24:32 -04:00
import-provider-var command: require resource to be in config before import 2017-06-09 14:03:59 -07:00
import-provider-var-default command: require resource to be in config before import 2017-06-09 14:03:59 -07:00
import-provider-var-file command: require resource to be in config before import 2017-06-09 14:03:59 -07:00
init command: init works at a basic level 2014-09-26 16:30:49 -07:00
init-012upgrade command: "terraform init" can partially initialize for 0.12upgrade 2019-01-14 11:33:21 -08:00
init-backend command: convert to use backends 2017-01-26 14:33:49 -08:00
init-backend-config-file command: convert to use backends 2017-01-26 14:33:49 -08:00
init-backend-config-file-change command: recompute config hash with ConfigFile set 2017-03-16 11:47:59 -07:00
init-backend-config-kv command/init: add test for -backend-config k/v 2017-03-17 10:22:48 -07:00
init-backend-empty add Rehash to terraform.BackendState 2017-03-29 15:53:42 -04:00
init-check-required-version command/init: check required_version 2017-08-28 11:25:16 -07:00
init-get command: convert to use backends 2017-01-26 14:33:49 -08:00
init-get-providers add init getPlugin test 2017-06-09 14:03:59 -07:00
init-internal add test for internal plugins with -plugin-dir 2018-01-05 11:51:09 -05:00
init-legacy-rc test loading of Meta.PluginOverrides 2017-08-09 11:13:54 -04:00
init-provider-lock-file command: produce provider lock file during "terraform init" 2017-06-09 14:03:59 -07:00
init-providers-lock command: produce provider lock file during "terraform init" 2017-06-09 14:03:59 -07:00
inmem-backend create failing test cases for remote lineage issue 2017-08-01 19:34:21 -04:00
parallelism command: Fix some tests for the "apply" command 2018-10-16 19:14:11 -07:00
plan command: Make suitable provider schemas available for all "plan" tests 2018-10-16 19:14:11 -07:00
plan-emptydiff command: plan supports detailed exit code 2015-04-01 09:38:19 -07:00
plan-invalid command: Fix most (but not all) "terraform plan" tests 2018-10-16 19:14:11 -07:00
plan-out-backend command: Fix testBackendState 2018-11-08 08:57:11 -08:00
plan-out-backend-legacy command: convert to use backends 2017-01-26 14:33:49 -08:00
plan-vars dos2unix 2014-07-28 10:43:00 -07:00
providers command: "terraform providers" command 2017-06-09 14:03:59 -07:00
push command: correct provider name in the test fixture for push 2017-06-09 14:03:59 -07:00
push-backend-new command/push: test for push with new backends 2017-03-16 10:52:58 -07:00
push-input command/push: read name from the config 2015-03-24 13:30:23 -07:00
push-input-partial command/push: read name from the config 2015-03-24 13:30:23 -07:00
push-no-remote command/push: don't allow pushing with local backend 2017-03-16 10:47:48 -07:00
push-no-upload command/push: make test more resilient 2016-08-26 13:38:02 -07:00
push-tfvars command/meta: validate config immediately 2016-09-03 15:26:49 -07:00
refresh dos2unix 2014-07-28 10:43:00 -07:00
refresh-empty backend/local: allow refresh on empty/non-existent state 2017-03-16 12:11:31 -07:00
refresh-output core: show outputs after `terraform refresh` 2015-06-15 10:41:42 -05:00
refresh-unset-var Add failing test replicating #4013 2015-11-23 10:32:46 +02:00
refresh-var dos2unix 2014-07-28 10:43:00 -07:00
show json output of terraform plan (#19687) 2018-12-19 11:08:25 -08:00
show-json command/show: tests for -json output (#19980) 2019-01-11 15:13:55 -08:00
state-list-backend-custom command/state: update and fix the state list command 2018-10-19 16:31:12 +02:00
state-list-backend-default command/state: update and fix the state list command 2018-10-19 16:31:12 +02:00
state-pull-backend command/state: update and fix the state push and pull 2018-10-19 19:12:23 +02:00
state-push-bad-lineage command: Use statemgr.Import and statemgr.Export for state push and pull 2018-11-19 09:02:35 -08:00
state-push-good command/state: update and fix the state push and pull 2018-10-19 19:12:23 +02:00
state-push-replace-match command/state: update and fix the state push and pull 2018-10-19 19:12:23 +02:00
state-push-serial-newer command/state: update and fix the state push and pull 2018-10-19 19:12:23 +02:00
state-push-serial-older command/state: update and fix the state push and pull 2018-10-19 19:12:23 +02:00
validate-invalid command: beginnings of new config loader in "terraform validate" 2018-10-16 18:20:32 -07:00
validate-valid command/validate: read terraform.tfvars file for variable values 2017-08-28 12:01:11 -07:00
.gitignore Remove test output file accidentally added in 52c97e9f 2017-10-03 17:32:26 -07:00
empty-file Re-integrate the "terraform" provider into the main binary 2017-11-03 11:36:31 -07:00