Commit Graph

27887 Commits

Author SHA1 Message Date
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
Pam Selle 80ad3924de
Update CHANGELOG.md 2021-01-13 12:43:06 -05:00
Pam Selle d34e1d926a
Merge pull request #27484 from hashicorp/pselle/revision
Remove revision from version command
2021-01-13 12:42:09 -05:00
Alisdair McDiarmid ddac282553 cli: Fix double check of remote workspace version
After verifying the remote backend workspace version is compatible with
the local Terraform version, we need to record that this check was
successful. Otherwise the fallback error handling path will run a strict
version check, even if the versions are compatible, which will cause an
unexpected failure.
2021-01-13 10:43:35 -05:00
James Bardin dcf49dc7dd
Merge pull request #27491 from hashicorp/jbardin/private-data-error
preserve resource private data on error
2021-01-13 09:00:27 -05:00
James Bardin e0d3b97c8e preserve resource private data on error
If the provider returns an empty response during apply, we restore the
prior state for the resource, but the private data was not being
restored.
2021-01-13 08:31:32 -05:00
James Bardin 7e880299c0
Merge pull request #27485 from hashicorp/jbardin/mock-provider
Update the MockProvider to use correct types and allow default behaviors
2021-01-13 08:25:07 -05:00
Rémy Léone edb4c00a86
website: add links to the registry provider documentation (#27416)
* docs: add links to the registry provider documentation

* Adjust wording/link URL

Co-authored-by: Nick Fagerlund <nick@hashicorp.com>
2021-01-12 16:06:50 -08:00
Nick Fagerlund 303b326008
Merge pull request #27279 from kowshikRoy/add-var-multiple-example
website: add example of multiple var cli
2021-01-12 15:58:31 -08:00
James Bardin 3bc7d77230 update MockProvider usage 2021-01-12 17:47:55 -05:00
James Bardin 2e2c9e07e5 add default behavior to the MockProvider
Add reasonable default behavior to the mock provider, so that may do not
need to depend on the idiosyncrasies of the old (though updated) test
testDiffFn and to a lesser extend the testApplyFn. This behavior is
based directly upon the documented resource lifecycle, rather
than be an ad-hoc collection of behaviors from old tests.

As a proof of concept, remove all uses of testDiffFn from the plan
context tests that don't cause the tests to fail.
2021-01-12 17:47:55 -05:00
Nick Fagerlund 66f2c82d33 website: Add version command to sidebar nav and to plugins overview page 2021-01-12 14:40:45 -08:00
Nick Fagerlund ccb205896d website: Fix alphabetical ordering of commands 2021-01-12 14:34:45 -08:00
Pam Selle cf0c54f834 Add documentation page for version
The version command, although not the mightiest of our commands,
did not have a page among our docs.
2021-01-12 17:06:53 -05:00
Pam Selle 83e6703bf7 Remove revision from version command
The revision field is only populated on dev builds so this means
most releases of Terraform have an empty "terraform_revision" field
in the JSON output. Since we recommend developers use go tooling
to `go build` this tool when developing, the revision is not useful
data and so it is removed.
2021-01-12 16:35:30 -05:00
James Bardin e01d37d0dc Block.AttribuuteByPath
There are a few places where we want to perform some transformation on a
cty.Value, but require information from the schema. Rather than create
bespoke functions to walk the cty.Value and schema in concert, we can
provide Attribute information from a cty.Path allowing the use of
Value.Transform in these cases.
2021-01-12 16:31:18 -05:00
James Bardin 7dd570ef6c change mock provider to use GetSchemaResponse
This ensures that test providers are using the same types as actual
providers.
2021-01-12 16:31:18 -05:00
James Bardin 5fe848b642 change mock return values to pointers
This allows up to detect an unset value from the zero value so that
defaults can be implemented, while still allowing tests to return
specific values of their choosing.
2021-01-12 15:16:48 -05:00