Commit Graph

28255 Commits

Author SHA1 Message Date
Alisdair McDiarmid a7d50d3264
Merge pull request #27545 from hashicorp/alisdair/remote-backend-version-check-state-migration
cli: Fix state migration remote version check
2021-01-20 11:07:59 -05:00
James Bardin 0403d89083
Merge pull request #27549 from hashicorp/jbardin/provisioner-lifecycle
Provisioner lifecycle
2021-01-20 10:50:18 -05:00
James Bardin 439d06b29f comment updates 2021-01-20 10:33:57 -05:00
James Bardin 21896f74af builtin provisioner e2e test 2021-01-19 17:48:30 -05:00
James Bardin ff30030e4f builtin provisioners are re-used and not Closed 2021-01-19 17:48:30 -05:00
James Bardin 63a9ab4944 ensure that provisioners are not used after Close 2021-01-19 17:48:30 -05:00
James Bardin fe7635f438 always close all provisioners after each walk
This was not done consistently in all cases when the individual
provisioner graph nodes were used. Since we removed the graph nodes, the
only thing left is to close these at the end of the walk.
2021-01-19 17:48:30 -05:00
James Bardin a6db207b87 remove provisioner graph nodes
Provisioners are always run via a single instance, and their
configuration and references are taken care of via their parent
resource, so there is no need to maintain the provisioner graph nodes.

The only action that will still need to be completed is calling the
Close method for external plugins. This was not consistently done with
the current handling of provisioners anyway, and we can now add that to
a single point with the new CloseProvisioners context method.
2021-01-19 15:54:19 -05:00
James Bardin 44daf76624 remove InitProvisioner and close all at once
InitProvisioner only stored the provisioner in the cache and provided a
way to return an error. We can push this back further into the cli init
process, but for now we can move the error into the Provisioner call and
drop InitProvisioner.

This also changes CloseProvisioner to CloseProvisioners, in preparation
for the removal of the graph nodes.
2021-01-19 15:54:19 -05:00
Alisdair McDiarmid 212a97c3bd cli: Fix state migration remote version check
Previously the state migration process was using the fallback strict
error check when migrating to or from a Terraform Cloud workspace. This
resulted in an error when running init if the local and remote Terraform
versions did not exactly match.

This was excessively strict. When migrating from a remote Terraform
Cloud workspace to local state, there is no need for a version check at
all, as we cannot break the Terraform Cloud workspace. When migrating
to Terraform Cloud, we should use the more forgiving check, rather than
the strict equality.

This commit fixes both of these cases accordingly, and allows migrating
state to and from Terraform Cloud remote workspaces without errors.
2021-01-19 11:38:31 -05:00
fredtrimble 7b3b401da4
Update index.html.md
Change the word "date" to "data"
2021-01-16 10:49:37 -05:00
njucz e62979acfe fix slash issue on windows 2021-01-15 15:53:06 +08:00
Nick Fagerlund 1c7c53adbb
Merge pull request #27404 from hashicorp/jan21_broken_link_check
CI: Add broken link checking job for website content
2021-01-14 15:24:45 -08:00
Martin Atkins 54ebe6a95a
Update CHANGELOG.md 2021-01-14 09:52:43 -08:00
Martin Atkins e865faf318 command: Better visual hierarchy for diagnostics
I frequently see people attempting to ask questions about Terraform's
error and warning messages but either only copying part of the message or
accidentally copying a surrounding paragraph that isn't part of the
message.

While I'm sure some of these are just "careless" mistakes, I've also
noticed that this has sometimes overlapped with someone asking a question
whose answer is written directly in the part of the message they didn't
include when copying, and so I have a theory that our current output
doesn't create a good enough visual hierarchy for sighted users to
understand where the diagnostic messages start and end when we show them
in close proximity to other content, or to other diagnostic messages.
As a result, some folks fail to notice the relevant message that might've
answered their question.

I tried a few different experiments for different approaches here, such
as adding more horizontal rules to the output and coloring the detail
text differently, but the approach that felt like the nicest compromise
to me was what's implemented here, which is to add a vertical line
along the left edge of each diagnostic message, colored to match with the
typical color we use for each diagnostic severity. This means that the
diagnostics end up slightly indented from what's around them, and the
vertical line seems to help subtly signal how we intended the content
to be grouped together.
2021-01-14 09:50:22 -08:00
James Bardin ef7607df04 update CHANGELOG.md 2021-01-14 11:15:05 -05:00
James Bardin 68b65cc98a
Merge pull request #27512 from hashicorp/jbardin/output-plans
Create and Delete actions for output plans
2021-01-14 11:09:23 -05:00
Alisdair McDiarmid a15c5c84a3
Merge pull request #27498 from hashicorp/alisdair/fix-remote-terraform-version-check-again
cli: Fix double check of remote workspace version
2021-01-14 11:02:28 -05:00
James Bardin 191124e9c9 detect new outputs and plans as Create actions
Rather than using a prior value of null to indicate create, which is
imprecise because null is a valid output value, only plan values that
didn't exist in the prior state as Create changes.
2021-01-14 10:54:23 -05:00
Pam Selle 3a50831604
Update CHANGELOG.md 2021-01-14 10:05:12 -05:00
Pam Selle 4ffacc8d4a
Merge pull request #27502 from hashicorp/pselle/untaint-missing
Add name to untaint missing warning
2021-01-14 10:04:39 -05:00
Pam Selle 63efb12ca9
Update CHANGELOG.md 2021-01-14 10:03:11 -05:00
Pam Selle 1e10051cad
Merge pull request #27501 from hashicorp/pselle/taint-err
Show resource name in taint -allow-missing warning
2021-01-14 10:02:21 -05:00
James Bardin 89f580b555
Merge pull request #27505 from hashicorp/jbardin/context-tests
Context test updates
2021-01-14 09:29:48 -05:00
James Bardin 57f004e0ef existing outputs can only be Updated
The planning logic here was inspired by resources, but unlike resources
a null value is valid for an output and does not necessarily indicate it
is being removed. If both before and after are null, the change should
be NoOp. When an output is removed from the configuration, we have a
separate node to create a Delete action to remove it from the state.
2021-01-14 08:59:31 -05:00
Nick Fagerlund bf5522aaec Remove website-test task from Makefile
This task relied on using `wget` to spider the entire site, which is no longer a
useful way of checking for broken links on a non-production instance of
terraform.io. Also, it didn't include a step for pausing until the server came
online, so the task wouldn't have functioned properly anyway.
2021-01-13 17:35:54 -08:00
Martin Atkins 296c48405b
Update CHANGELOG.md 2021-01-13 15:50:19 -08:00
Martin Atkins 1f1af87dea command/format: Don't try to fill the last terminal column
In some terminal emulators, writing a character into the last column on a
row causes the terminal to immediately wrap to the beginning of the next
line, even if the very next character in the stream is a hard newline.
That can then lead to errant blank lines in the final output which make
it harder to navigate the visual hierarchy.

As a compromise to avoid this, we'll format our horizontal rules and
paragraphs to one column less than the terminal width. That does mean that
our horizontal rules won't _quite_ cover the whole terminal width, but
it seems like a good compromise in order to get consistent behavior across
a wider variety of terminal implementations.
2021-01-13 15:37:04 -08:00
Martin Atkins 0c84a56700 command/format: Use box drawing chars for rules in diagnostics
We were previously using some ASCII art to create some visual divisions
between parts of the diagnostic output. Now that we are requiring a UTF-8
terminal we can print out box drawing characters instead.
2021-01-13 15:37:04 -08:00
Martin Atkins e6a516d87e backend/local: Use terminal properties to tweak the plan output
We now require the output to accept UTF-8 and we can determine how wide
the terminal (if any) is, so here we begin to make use of that for the
"terraform plan" command.

The horizontal rule is now made of box drawing characters instead of
hyphens and fills the whole terminal width.

The paragraphs of text in the output are now also wrapped to fill the
terminal width, instead of the hard-wrapping we did before.

This is just a start down the road of making better use of the terminal
capabilities. Lots of other commands could benefit from updates like these
too.
2021-01-13 15:37:04 -08:00
Martin Atkins d2c3403ab6 command: Use the new terminal.Streams object
Here we propagate in the initialized terminal.Streams from package main,
and then onwards to backends running in CLI mode.

This also replaces our use of helper/wrappedstreams to determine whether
stdin is a terminal or a pipe. helper/wrappedstreams returns incorrect
file descriptors on Windows, causing StdinPiped to always return false on
that platform and thus causing one of the odd behaviors discussed in

Finally, this includes some wrappers around the ability to look up the
number of columns in the terminal in preparation for use elsewhere. These
wrappers deal with the fact that our unit tests typically won't populate
meta.Streams.
2021-01-13 15:37:04 -08:00
Martin Atkins 15c0645bd5 main: initialize the terminal (if any) using internal/terminal
We need to call into terminal.Init in early startup to make sure that we
either have a suitable Terminal or that we disable attempts to use virtual
terminal escape sequences.

This commit gets the terminal initialized but doesn't do much with it
after that. Subsequent commits will make more use of this.
2021-01-13 15:37:04 -08:00
Martin Atkins 17728c8fe8 internal/terminal: Interrogate and initialize the terminal, if any
This is a helper package that creates a very thin abstraction over
terminal setup, with the main goal being to deal with all of the extra
setup we need to do in order to get a UTF-8-supporting virtual terminal
on a Windows system.
2021-01-13 15:37:04 -08:00
Nick Fagerlund 96ec703a8c CI: Add broken link checking job for website content
This adds a CI job for running the new PR link checker for documentation.

[terraform-website PR 1574](https://github.com/hashicorp/terraform-website/pull/1574)
added a new link checking CI job specifically for warning about broken links in
pull requests. This link checker is optimized for:

- Running (relatively) quickly.
- Only reporting on files that were changed in the current PR, to avoid spamming
  you with problems you had nothing to do with.
- Being transparent and simple to maintain. (Note that this is in conflict with
  minimizing false positives/negatives! We try to give very few of both, but
  completely eliminating them would result in an unaffordable maintenance
  burden. We expect that some PRs will be merged with this job red.)

The tool is somewhat specific to our Middleman site builder, and we expect it
will be replaced or obviated in the transition to the Next.js platform... but in
the meantime, it should help make documentation slightly easier to maintain.
2021-01-13 15:09:41 -08:00
James Bardin 54523991a2 test for invalid nil value during apply 2021-01-13 17:51:05 -05:00
James Bardin e075c8ab8b remove unneeded testDiffFn and testApplyFn calls
Remove any calls to testDiffFn and testApplyFn which don't effect the
test result. This way we have more tests using predictable provider
behavior, which is more likely to uncover legitimate regressions as the
particular behavior of the legacy mock provider logic does not need to
be taken into account.
2021-01-13 17:36:32 -05:00
Pam Selle 0a086030b1
Update CHANGELOG.md 2021-01-13 16:44:34 -05:00
Pam Selle e6d02aec16
Merge pull request #27482 from hashicorp/pselle/state_mv
Make errors in state mv more accurate
2021-01-13 16:43:19 -05:00
James Bardin 40b3f51576
Merge pull request #27503 from hashicorp/jbardin/instance-apply-refactor
Fix error handling in instance apply methods
2021-01-13 16:29:42 -05:00
James Bardin 3a6e2b322d comment update 2021-01-13 16:24:31 -05:00
Kristin Laemmert 86a63e8e39
remove unused legacy plugin package (#27493) 2021-01-13 16:13:08 -05:00
James Bardin cb0d50436e retain diagnostics with non-conforming response 2021-01-13 15:46:46 -05:00
James Bardin 833647bdfd make the diagnostics handling of apply easier
Now that we don't need to track separate error values for the apply
logic, it's easier to reorganize the diagnostic handling to use a single
set of diagnostics.
2021-01-13 15:27:17 -05:00
James Bardin 3f3565d48a don't use an *error in the postApplyHook 2021-01-13 15:14:32 -05:00
Pam Selle b25d0251ca Add name to untaint missing warning 2021-01-13 15:14:19 -05:00
James Bardin 685022fae7 stop passing errors into the instance apply method
Trying to track these error values as they wint into and out of the
instance apply methods was quite difficult. They were mis-assigned, and
in many cases lost diagnostic information.
2021-01-13 15:08:53 -05:00
Pam Selle 67853d8fa8 Show resource name in taint -allow-missing warning
Show the resource name in the warning when allow-missing
is used and no resource matches
2021-01-13 15:00:35 -05:00
James Bardin 1707685350 remove the applyError argument to apply
This was never assigned, and the empty value made the usage very
difficult to trace.
2021-01-13 14:09:20 -05:00
James Bardin 842c5b4136 ensure status, private, warnings, etc are retained
Various pieces of the state and/or warnings were dropped when the
provider returns an error. Do a little cleanup of `.apply` to make the
logic easier to follow.
2021-01-13 13:37:20 -05:00
Pam Selle 61f9d2177b
Merge pull request #27486 from hashicorp/pselle/version-doc
Add documentation page for version
2021-01-13 12:44:11 -05:00