Commit Graph

22828 Commits

Author SHA1 Message Date
James Bardin eddf676c1f add provider test with a nested list in a set
in some cases helper/schema misses the list counts.
2018-11-16 15:11:16 -05:00
James Bardin 3716db3865
Merge pull request #19384 from hashicorp/jbardin/nested-sets
New Attribute and Diff handling in shims
2018-11-16 11:55:41 -05:00
James Bardin 89b2c6f21e comment fixes 2018-11-16 11:24:14 -05:00
James Bardin a681124301 verify DiffSuppresFunc behavior
Terraform used to provide empty diffs to the provider when calculating
`ignore_changes`, which would cause some DiffSuppressFunc to fail, as
can be seen in #18209.

Verify that this is no longer the case in 0.12
2018-11-16 11:17:23 -05:00
James Bardin 17ecda53b5 strip empty containers from flatmap attributes
In order to prevent mismatched states between read/plan/apply, we need
to ensure that the attributes are generated consistently each time.
Because of the various ways in which helper/schema and the hcl2 shims
interpret empty values, the only way to ensure consistency is to always
remove them altogether.
2018-11-16 09:59:03 -05:00
James Bardin 83317975fe add more tests with carious set combinations 2018-11-16 09:59:03 -05:00
James Bardin 21dfa56766 use ShimInstanceStateFromValue in DiffFromValues
This makes sure the diff is generated with the matching set ids from
helper/schema.

Update the tests to add ID fields to the state, which will exists in
practice, since any state traversing through the shims will have the ID
inserted.
2018-11-16 09:59:03 -05:00
James Bardin 71b55601ce new failing tests for nested sets 2018-11-16 09:59:03 -05:00
James Bardin 16f28f7348 new mechanism for applying a diff to a value
This attempts to apply the diff in order to get consistent output from
the shimmed values.
2018-11-16 09:59:03 -05:00
James Bardin 34766ca666 use the new InstanceState shim 2018-11-16 09:59:03 -05:00
James Bardin df04e2e7a6 move InstanceState shim into schema.Resource
This was the resource can rebuild the flatmapped state using the
schema and ResourceData, providing us the the correct set key values.
2018-11-16 09:59:03 -05:00
James Bardin b872491baa incremental progress towards applying diffs 2018-11-16 09:58:42 -05:00
Sander van Harmelen 812e7f66aa
Merge pull request #19375 from hashicorp/svh/b-atlas
Make the Atlas backend work after updating depencies
2018-11-15 20:47:34 +01:00
Sander van Harmelen 04439595ab Make the Atlas backend work after updating depencies
Newer versions of the retryablehttp package use a context, so we need to
add that in our custom `CheckRetry` function.

In addition I removed the `return true, nil` to continue retrying in
case of an error, and instead directly call the `DefaultRetryPolicy`.
This is because the `DefaultRetryPolicy` will now also take the context
into consideration.
2018-11-15 20:34:31 +01:00
Sander van Harmelen 7a268f1e48
Merge pull request #19374 from hashicorp/b-state-migration
Fix wildcard dependencies when upgrading states
2018-11-15 17:11:52 +01:00
Sander van Harmelen 634430ebb2 Fix wildcard dependencies when upgrading states
Fixes #19347
2018-11-15 13:17:15 +01:00
James Bardin d2bd41c260 add a nested set test 2018-11-13 18:53:02 -05:00
James Bardin ce5d7ff6d0 spelling 2018-11-13 18:41:53 -05:00
James Bardin 6fee1f24ab don't add duplicate unknowns to a set
The flatmap shim was lazily adding duplicate items and letting cty.Set
clear them out, but if those duplicates contains unknown values they
can't be checked for equality and will end up remaining in the set.
2018-11-13 18:41:53 -05:00
James Bardin ebc9745788 fix "too many items" error message 2018-11-13 18:41:53 -05:00
James Bardin c4d0be8a52 failing test for schemas with a single set attr
Resources with certain combinations of attributes in a nested single set
fail to perperly coerce their shimmed values.
2018-11-13 18:41:53 -05:00
Paddy 2a6ad820bb
Merge pull request #19271 from danawillow/test-state
return state in tests even if cfg is invalid
2018-11-13 14:39:41 -08:00
Sander van Harmelen 785307f4fb
Merge pull request #19359 from hashicorp/f-update-deps
depencies: update `go-tfe`
2018-11-13 17:28:58 +01:00
Sander van Harmelen d0c320f148 depencies: update `go-tfe` 2018-11-13 16:24:45 +01:00
Dana Hoffman 7edbb3c8bf return state even if cfg is invalid 2018-11-12 21:49:30 -05:00
Martin Atkins 8c54da0ad2 command: TestInit_fromModule_explicitDest guard against other tests
Some other test is leaving behind a terraform.tfstate after it concludes,
which can cause this test to fail in a strange way due to picking up
extra provider requirements from that state.

This check doesn't fix that problem, but it at least makes the test fail
in a more helpful way to avoid time wasted trying to debug this test when
it's some other test that actually has the bug.
2018-11-12 15:19:55 -08:00
Martin Atkins ced06a4ca3 command: fix panic in TestStatePush_lineageMismatch
This test is currently failing due to the command completing successfully,
which would previously cause a panic because we didn't properly initialize
the MockUi and so its error buffer is nil unless written to.

(The failure this was masking will be fixed in a subsequent commit.)
2018-11-12 15:19:55 -08:00
Martin Atkins 544c2932ce command: Fix TestInit_checkRequiredVersion
In prior refactoring we lost the required core version check from
"terraform init", which we restore here.

Additionally, this test used to have an incorrect name that suggested it
was testing something in the "getProvider" codepath, but version checking
happens regardless of what other options are selected.
2018-11-12 15:19:55 -08:00
Martin Atkins 9ba399bca8 command: Fix TestInit_getProvider
After all of the refactoring we were no longer checking the Terraform
version field in a state file, causing this test to fail.

This restores that check, though with a slightly different error message.
2018-11-12 15:19:55 -08:00
Martin Atkins f6d468ffd5 command: Fix TestInit_inputFalse
This test was using old-style state files as its input, differing only by
lineage. Since lineages are now managed within the state manager itself,
the test can't use that to distinguish the two files and so we put a
different output in each one instead.

This also introduces some TRACE logging to the migration codepaths.
There's some hard-to-follow control flow here and so this extra logging
helps to understand the reason for a particular outcome, and since this
codepath is visited only in "terraform init" anyway it doesn't hurt to
be a bit more verbose here.
2018-11-12 15:19:55 -08:00
Martin Atkins c0b7f58143 command: Fix detection of necessary backend migration
In the refactoring for new HCL this codepath stopped taking into account
changes to the CLI -backend-config options when deciding if a backend
migration is required.

This restores that behavior in a different way than it used to be: rather
than re-hashing the merged config and comparing the hashes, we instead
just compare directly the configuration values, which must be exactly
equal in order to skip migration.

This change is covered by the test TestInit_inputFalse, although as of
this commit it is still not passing due a downstream problem within the
migration code itself.
2018-11-12 15:19:55 -08:00
Sander van Harmelen 3c850947a7
Merge pull request #19350 from hashicorp/b-select-workspace
backend/migrations: only select workspaces if supported
2018-11-12 17:15:42 +01:00
Sander van Harmelen 5e9414bf03 backend/migrations: only select workspaces if supported
If the backend does not support workspaces, we don't have to try to
select a workspace and we should not return an error.
2018-11-12 16:51:32 +01:00
Kristin Laemmert f625fb5f6a
Merge pull request #19348 from seishun/patch-1
website: add missing article
2018-11-12 09:56:32 -05:00
Kristin Laemmert a2746763a1
Update CHANGELOG.md 2018-11-12 09:27:10 -05:00
Nikolai Vavilov e10cf6dabd
website: add missing article 2018-11-11 23:15:11 +02:00
Martin Atkins 297b3b8830 command: Fix TestInit_backendReinitConfigToExtra
This test was re-using the same InitCommand value to run multiple times,
which is not realistic. Since we now cache configuration source code
inside command.Meta on load, it's important that we use a fresh
InitCommand instance here so it'll see the modified configuration file
we've left on disk.
2018-11-09 09:48:03 -08:00
Martin Atkins b5547f00f6 command: backendConfig must mutate its copy, not the original
Here we were going to the trouble of copying the body so we could mutate
it, but then ended up mutating the original anyway and then returning the
unmodified copy. Whoops!

This fix is verified by a number of "init" command tests that exercise the
-backend-config option, including TestInit_backendConfigFile and several
others whose names have the prefix TestInit_backendConfig .
2018-11-09 09:48:03 -08:00
Martin Atkins f001cb8654 command: Fix terraform init -from-module with relative paths
Since our new approach here works by installing with a synthetic module
configuration block, we need to treat relative paths as a special case
for two reasons:

- Relative paths in module addresses are relative to the file containing
  the call rather than the working directory, but -from-module uses the
  working directory (and the call is in a synthetic "file" anyway)

- We need to force Terraform to pass the path through to go-getter rather
  than just treating it as a relative reference, since we really do want
  a copy of the directory in this case, even if it is local.

To address both of these things, we'll detect a relative path and turn it
into an absolute path before beginning installation. This is a bit hacky,
but this is consistent with the general philosophy of the -from-module
implementation where it does hacky things so that the rest of the
installer code can be spared of dealing with its special cases.

This is covered by a couple of existing tests that run init -from-module,
including TestInit_fromModule_dstInSrc which now passes.
2018-11-09 09:48:03 -08:00
Martin Atkins 8b603e4877 command: Name the Terraform Registry specifically in error message
When we originally wrote this message we struggled a bit for how to refer
to the releases server without writing an awkwardly-ungrammatical
sentence, and so "the official repository" became a placeholder name for
it.

Now that we'll be looking in Terraform Registry this gives us a nice
proper noun to use. This message will need to evolve more as our
integration with the registry gets more sophisticated, but for now this
works.
2018-11-09 09:48:03 -08:00
Martin Atkins 592850e22c command: Fix TestApply_plan_remoteState
Some over-zealous bulk updating of this test file caused this test to be
producing a remote state config cache file on disk when it doesn't
actually need one: the backend config comes from the plan file when
applying a saved plan.
2018-11-09 09:48:03 -08:00
Martin Atkins c05a556c0e command: Fix TestRefresh_backup
This test intentionally overrides the backup file location using the
-backup option, so the backup file is not in the default location for this
one.
2018-11-09 09:48:03 -08:00
Martin Atkins ad276142b4 command: Fix the command package test build
Some merging conflict shenanigans here led to this usage not lining up
with the imported symbol name, meaning that the tests couldn't compile any
more.
2018-11-08 14:39:24 -08:00
Martin Atkins 6806d7cba5 vendor: catch up vendoring
We've missed a few recent additions to go.mod in the vendor directory. We
need to keep this updated for the moment until all of the surrounding
tooling is ready to go all-in with Go 1.11 modules.
2018-11-08 14:20:19 -08:00
Martin Atkins 1e45d30036 command: Fix TestPlan_outBackend
We missed fixing this up during the big updates for the new plan/state
models since the failures were being masked by testBackendState being
broken.

This is the same sort of update made to many other tests: add schema to
the mock provider, adjust for the new plan/state types, and make
allowances for the new built-in diffing behavior in core.
2018-11-08 08:57:11 -08:00
Martin Atkins c3d11b762b command: Fix testBackendState
The hashing function for cached backend configuration is different now, so
our hard-coded hash of the HTTP backend address wasn't working anymore.

Here we update the hash so that tests using this test backend will work
again. Rather than leaving it hard-coded, we'll instead compute it the
same way as "terraform init" would.

In practice only one test is actually using this function right now, so
we also update the test fixture for that test (TestPlan_outBackend) to
match the new expectations, though as of this commit it's still failing
with an unrelated error.
2018-11-08 08:57:11 -08:00
Martin Atkins e20346bf4f command: fix TestMeta_process
The mission of this process method used to include dealing with
auto-loaded tfvars files, but it doesn't do that anymore.

It does still deal with the -no-color option, but the test wasn't
exercising that part before.

Now the test here focuses on the -no-color behavior.

The process method still has a "vars" flag argument which is no longer
used. Since this is an unexported method we could potentially address this
but this commit is intentionally limited only to fixing the test.
2018-11-08 08:57:11 -08:00
Martin Atkins fcf3f643ce command: Fix TestPlan_shutdown
Comments here indicate that this was erroneously returning an error but
we accepted it anyway to get the tests passing again after other work.
The tests over in the "terraform" package agree that cancelling should be
a successful outcome rather than an error.

I think that cancelling _should_ actually be an error, since Terraform did
not complete the operation it set out to complete, but that's a change
we'd need to make cautiously since automation wrapper scripts may be
depending on the success-on-cancel behavior.

Therefore this just fixes the command package test to agree with the
Terraform package tests and adds some FIXME notes to capture the potential
that we might want to update this later.
2018-11-08 08:57:11 -08:00
Martin Atkins 0ea8aa6fe5 command: Fix TestWorkspace_createWithState
The State.Equal function is now more precise than this test needs. It's
only trying to distinguish between an empty state and a non-empty state,
so the string representation of state is good enough to get that done
while disregarding other subtle differences.
2018-11-08 08:57:11 -08:00
Kristin Laemmert 1be09745d7
Merge pull request #19007 from cardoe/fix-swift-backend-docs
Fix backend/swift docs
2018-11-08 06:34:09 -08:00