Commit Graph

26981 Commits

Author SHA1 Message Date
Kristin Laemmert 479655ad47 refactor tests to use modern states.State in favor of terraform.State where possible 2020-09-30 16:07:54 -04:00
James Bardin c51104fb7c
Merge pull request #26435 from hashicorp/jbardin/races
Fix race conditions
2020-09-30 15:19:58 -04:00
James Bardin 59110a2ca5 e2etest server was unsynchronized 2020-09-30 14:28:02 -04:00
Pam Selle ada6f45871 Add test file for bad sensitive value
Adds a test file for an incorrectly typed
(non-boolean) sensitive value to ensure it errors
2020-09-30 13:58:01 -04:00
James Bardin a3c9b33b7b output buffer must be synchronized 2020-09-30 13:44:07 -04:00
James Bardin ab6d6f99ae fix races in remote backend mock 2020-09-30 13:36:04 -04:00
James Bardin b464bcbc5d copy the refreshed state at the end of plan
Otherwise we may end up with the same state value for the state and
refreshState when re-using the context.
2020-09-30 12:14:37 -04:00
James Bardin 8dc6f518c2 don't use same state in Validate for refreshState 2020-09-30 12:14:37 -04:00
James Bardin 8c699fbe32 Unsynchronized maps in test 2020-09-30 12:14:31 -04:00
Martin Atkins b0f58479c5
Update CHANGELOG.md 2020-09-30 09:04:00 -07:00
Pam Selle e369fe0559 Docs for sensitive variables 2020-09-30 11:57:03 -04:00
Pam Selle b57248533d Re-organize variable page for sensitive argument addition 2020-09-30 11:57:03 -04:00
Martin Atkins 59b116f7bf command/init: Remove support for legacy provider addresses
We no longer need to support 0.12-and-earlier-style provider addresses
because users should've upgraded their existing configurations and states
on Terraform 0.13 already.

For now this is only checked in the "init" command, because various test
shims are still relying on the idea of legacy providers the core layer.
However, rejecting these during init is sufficient grounds to avoid
supporting legacy provider addresses in the new dependency lock file
format, and thus sets the stage for a more severe removal of legacy
provider support in a later commit.
2020-09-30 08:54:57 -07:00
James Bardin bdef106a8b WithPath should only modify the copy 2020-09-30 11:50:50 -04:00
Kristin Laemmert c258e8efbb
Merge pull request #26413 from hashicorp/mildwonkey/the-rest-of-the-owl-tree
The Last Chapter in our Epic Saga: `EvalTree()` Refactor
2020-09-30 10:48:03 -04:00
Owen Tuz 5453147381 Fix bad string match that was causing TestInitProviderNotFound to fail on Macs
The tmp directory path is longer on Macs than other systems and was wrapping
across lines when printed, breaking the string match in the test.

Fix suggested by @apparentlymart is to add two spaces before the leading
'-' when printing to prevent the diagnostic renderer wrapping the line.
2020-09-30 09:30:02 +01:00
Rémi Lapeyre 9acfe30ca6 Always have the default workspace in the pg backend
Closes https://github.com/hashicorp/terraform/issues/23121
2020-09-29 23:18:34 +02:00
James Bardin a78d75ccfb
Merge pull request #26387 from hashicorp/jbardin/ignore-changes-2
Fix handling of ignore_changes
2020-09-29 15:35:29 -04:00
Kristin Laemmert 0ac53ae3ed terraform: remove deprecated or unused Eval() bits 2020-09-29 15:01:24 -04:00
Pam Selle a82b495683
Merge pull request #26417 from hashicorp/pk-provisioner-deprecation
Updating CODEOWNERS with our deprecated status for tool-specific provisioners
2020-09-29 14:59:25 -04:00
Kristin Laemmert 184893d1e4 evaltree refactor 2020-09-29 14:31:20 -04:00
Petros Kolyvas 3ea5175feb Updating codeowners with our deprecated status for tool-specific provisioners 2020-09-29 14:19:56 -04:00
Martin Atkins f53264d378 command/init: Better error message for provider unsupported platform
As we add and remove support for different target platforms over time,
there will be transition periods where the available platforms for
each provider will be different than the available platforms for Terraform
CLI itself.

In recognition of that possibility, here we add a more specialized error
message for that situation which tries to explain the problem a little
more clearly than the generic error message that came before it.

In an ideal world we'd be able to detect situations where a newer or older
version has support in a similar vein to what we do with provider protocol
incompatibilities, but we don't currently have logic to fetch the data
necessary to implement that, so this is instead a presentation-only change
aimed at allowing some possible near-future changes to the supported
target platforms.
2020-09-29 10:28:26 -07:00
Kristin Laemmert c66494b874 terraform: refactor NodeDestroyDeposedResourceInstanceObject and NodePlanDeposedResourceInstanceObject
The various Eval()s will be refactored in a later PR.
2020-09-29 13:26:50 -04:00
Kristin Laemmert 3bb64e80d5 apply refactor 2020-09-29 13:26:50 -04:00
Kristin Laemmert 26260c47f0 terraform: add ReadDiff method on NodeAbstractResourceInstance to replace EvalReadDiff 2020-09-29 13:26:50 -04:00
Kristin Laemmert ff5d78ff5a EvalReduceDiff: removing unused struct field 2020-09-29 13:25:17 -04:00
Kristin Laemmert f835841c28 terrafrom: create CheckPreventDestroy method on NodeAbstractResource
This will eventually replace all uses of EvalCheckPreventDestroy.
2020-09-29 13:24:21 -04:00
Kristin Laemmert ab5bf50fc3 terrafrom: create NodeAbstractResource ReadResourceInstanceState
function

The original EvalReadState node is used only by `NodeAbstractResource`s,
so I've created a new method on NodeAbstractResource which does the same
thing as EvalReadState. When the EvalNode refactor project is complete,
EvalReadState will be removed entirely.
2020-09-29 13:24:21 -04:00
Kristin Laemmert d1cf0279fa terraform: NodePlannableResourceInstanceOrphan refactor 2020-09-29 13:24:21 -04:00
Kristin Laemmert 9c721a4131 terraform: improved refactor of EvalWriteResourceState
EvalWriteResourceState finds new life as a method called WriteResourceState on NodeAbstractResource.
2020-09-29 13:24:21 -04:00
James Bardin a8981a954f don't use ignore_changes during replacement
When replacing an instance, we have to be sure to use the original
configuration which hasn't been processed with ignore_changes.
2020-09-29 13:15:33 -04:00
James Bardin 7fa4c00d1a add validation for ignore_changes references
Ensure that ignore_changes only refers to arguments set in the
configuration.
2020-09-29 13:15:33 -04:00
James Bardin 98124637d8 apply ignore_changes directly to config
In order to ensure all the starting values agree, and since
ignore_changes is only meant to apply to the configuration, we need to
process the ignore_changes values on the config itself rather than the
proposed value.

This ensures the proposed new value and the config value seen by
providers are coordinated, and still allows us to use the rules laid out
by objchange.AssertPlanValid to compare the result to the configuration.
2020-09-29 13:15:30 -04:00
James Bardin bc3fe5ddae diff should be from proposed, not config
This ensures the mock provider behaves like the shimmed legacy SDK
providers.
2020-09-29 13:15:03 -04:00
James Bardin 801f60fda8 only ignore changes from the configuration
ignore_changes should only exclude changes to the resource arguments,
and not alter the returned value from PlanResourceChange. This would
effect very few providers, since most current providers don't actively
create their plan, and those that do should be generating computed
values here rather than modifying existing ones.
2020-09-29 13:10:52 -04:00
Martin Atkins db9a9ed5a5
Update CHANGELOG.md 2020-09-29 10:01:47 -07:00
Martin Atkins 0b734a2803 command: Make provider installation interruptible
In earlier commits we started to make the installation codepath
context-aware so that it could be canceled in the event of a SIGINT, but
we didn't complete wiring that through the API of the getproviders
package.

Here we make the getproviders.Source interface methods, along with some
other functions that can make network requests, take a context.Context
argument and act appropriately if that context is cancelled.

The main providercache.Installer.EnsureProviderVersions method now also
has some context-awareness so that it can abort its work early if its
context reports any sort of error. That avoids waiting for the process
to wind through all of the remaining iterations of the various loops,
logging each request failure separately, and instead returns just
a single aggregate "canceled" error.

We can then set things up in the "terraform init" and
"terraform providers mirror" commands so that the context will be
cancelled if we get an interrupt signal, allowing provider installation
to abort early while still atomically completing any local-side effects
that may have started.
2020-09-29 10:00:35 -07:00
Martin Atkins f0ccee854c command/0.13upgrade: Remove this subcommand
We only preserve these major upgrade versions for one major version after
they are added, because our upgrade path assumes moving forward only one
major version at a time. Now that our main branch is tracking towards
Terraform 0.14, we no longer need the 0.13upgrade subcommand.

This also includes some minor adjustments to the 0.12upgrade command to
align the terminology used in the output of both commands. We usually
use the word "deprecated" to mean that something is still available but
no longer recommended, but neither of these commands is actually available
so "removed" is clearer.

We could in principle have removed even the removal notice for 0.12upgrade
here, but it's relatively little code and not a big deal to keep around
to help prompt those who might try to upgrade directly from 0.11 to 0.14.
We may still remove the historical configuration upgrade commands prior to
releasing Terraform 1.0, though.
2020-09-29 10:00:35 -07:00
Kristin Laemmert fc94c819e5
command: remove unused method on pluginSHA256LockFile (#26402)
* tmp is haunted
* remove unused code
2020-09-29 08:46:51 -04:00
Rémi Lapeyre 5c7008bd89 Merge remote-tracking branch 'origin/master' into consul-force-unlock 2020-09-29 10:59:36 +02:00
Thanonchai 85e83608fc
website: fix broken link to local backend in apply.html (#26307)
The link to local backend doesn't exist.  Update to what I believe is the correct one.
2020-09-28 16:09:34 -07:00
Alejandro Rosero Vicuña 6d66b8b616
website: Make template file extension more consistent (#25029)
Co-authored-by: Judith Malnick <judith.patudith@gmail.com>
2020-09-28 16:08:24 -07:00
Robin Norwood 7ccea30b28
website: Terraform import and remote backends (#26241)
* Put link to tutorial in its own section, call it a tutorial instead of guide, and use new canonical URL.

* Mention limitations of using import with a remote backed

* Typo fix

Co-authored-by: Nick Fagerlund <nick.fagerlund@gmail.com>
2020-09-28 16:03:15 -07:00
Kristin Laemmert d2247294c7
Update CHANGELOG.md 2020-09-28 13:13:09 -04:00
Nick McClendon 529ee04269
Fix taint and untaint commands when in a workspace (#22467)
* Fix taint and untaint commands when in a workspace

Fixes #22157. Removes DefaultStateFilepath as the default for the
-state flag, allowing workspaces to be used properly.

* update test with modern state types

Co-authored-by: Kristin Laemmert <mildwonkey@users.noreply.github.com>
2020-09-28 13:09:37 -04:00
Martin Atkins c05127c289
Update CHANGELOG.md 2020-09-28 09:09:23 -07:00
Martin Atkins ff0dbd6215 command/fmt: Restore some opinionated behaviors
In Terraform 0.11 and earlier, the "terraform fmt" command was very
opinionated in the interests of consistency. While that remains its goal,
for pragmatic reasons Terraform 0.12 significantly reduced the number
of formatting behaviors in the fmt command. We've held off on introducing
0.12-and-later-flavored cleanups out of concern it would make it harder
to maintain modules that are cross-compatible with both Terraform 0.11
and 0.12, but with this aimed to land in 0.14 -- two major releases
later -- our new goal is to help those who find older Terraform language
examples learn about the more modern idiom.

More rules may follow later, now that the implementation is set up to
allow modifications to tokens as well as modifications to whitespace, but
for this initial pass the command will now apply the following formatting
conventions:

 - 0.11-style quoted variable type constraints will be replaced with their
   0.12 syntax equivalents. For example, "string" becomes just string.
   (This change quiets a deprecation warning.)
 - Collection type constraints that don't specify an element type will
   be rewritten to specify the "any" element type explicitly, so
   list becomes list(any).
 - Arguments whose expressions consist of a quoted string template with
   only a single interpolation sequence inside will be "unwrapped" to be
   the naked expression instead, which is functionally equivalent.
   (This change quiets a deprecation warning.)
 - Block labels are given in quotes.

Two of the rules above are coming from a secondary motivation of
continuing down the deprecation path for two existing warnings, so authors
can have two active deprecation warnings quieted automatically by
"terraform fmt", without the need to run any third-party tools.

All of these rules match with current documented idiom as shown in the
Terraform documentation, so anyone who follows the documented style should
see no changes as a result of this. Those who have adopted other local
style will see their configuration files rewritten to the standard
Terraform style, but it should not make any changes that affect the
functionality of the configuration.

There are some further similar rewriting rules that could be added in
future, such as removing 0.11-style quotes around various keyword or
static reference arguments, but this initial pass focused only on some
rules that have been proven out in the third-party tool
terraform-clean-syntax, from which much of this commit is a direct port.

For now this doesn't attempt to re-introduce any rules about vertical
whitespace, even though the 0.11 "terraform fmt" would previously apply
such changes. We'll be more cautious about those because the results of
those rules in Terraform 0.11 were often sub-optimal and so we'd prefer
to re-introduce those with some care to the implications for those who
may be using vertical formatting differences for some semantic purpose,
like grouping together related arguments.
2020-09-28 09:04:03 -07:00
Martin Atkins 7951a6db0d command/fmt: Format using the full hclwrite syntax tree
Previously we were just using hclwrite.Format, a token-only formatting
pass. Now we'll do that via the full hclwrite parser, getting the
formatting as a side-effect of the parsing and re-serialization.

This should have no change in observable behavior as-is, but in a future
commit we'll add some additional processing rules that modify the syntax
tree before re-serializing it.
2020-09-28 09:04:03 -07:00
Martin Atkins 05f6a62399 command/fmt: Factor out the actual formatting
Previously formatting was just a simple wrapper around hclwrite.Format.
That remains true here, but the call is factored out into a separate
method in preparation for making it also do some Terraform-specific
cleanups in a future commit.
2020-09-28 09:04:03 -07:00