Commit Graph

28227 Commits

Author SHA1 Message Date
Pam Selle 156b1615a2 Remove 0.13upgrade test fixtures 2021-02-18 12:57:58 -05:00
Pam Selle 84696eae33
Merge pull request #27816 from jessicastenning/fix-docs-grammatical-mistake
Fix sentence in v0.14 upgrade guide
2021-02-18 12:37:53 -05:00
Pam Selle e1c25337c7 Delete readme, add doc.go to helper/schema
Remove the README that had old user-facing information, replacing
it with a doc.go that describes the package and points to the
plugin SDK for external consumers.
2021-02-18 12:30:10 -05:00
Alisdair McDiarmid 7f8b8a9046
Merge pull request #27808 from hashicorp/alisdair/command-views-operation-view
backend/local: Replace CLI with view instance
2021-02-18 12:14:33 -05:00
Alisdair McDiarmid 68558ccd54 backend/local: Replace CLI with view instance
This commit extracts the remaining UI logic from the local backend,
and removes access to the direct CLI output. This is replaced with an
instance of a `views.Operation` interface, which codifies the current
requirements for the local backend to interact with the user.

The exception to this at present is interactivity: approving a plan
still depends on the `UIIn` field for the backend. This is out of scope
for this commit and can be revisited separately, at which time the
`UIOut` field can also be removed.

Changes in support of this:

- Some instances of direct error output have been replaced with
  diagnostics, most notably in the emergency state backup handler. This
  requires reformatting the error messages to allow the diagnostic
  renderer to line-wrap them;
- The "in-automation" logic has moved out of the backend and into the
  view implementation;
- The plan, apply, refresh, and import commands instantiate a view and
  set it on the `backend.Operation` struct, as these are the only code
  paths which call the `local.Operation()` method that requires it;
- The show command requires the plan rendering code which is now in the
  views package, so there is a stub implementation of a `views.Show`
  interface there.

Other refactoring work in support of migrating these commands to the
common views code structure will come in follow-up PRs, at which point
we will be able to remove the UI instances from the unit tests for those
commands.
2021-02-18 12:08:08 -05:00
James Bardin 0da0b24527 provider transformer test mixing legacy stuff
Test a combination of new required_providers modules and legacy implied
providers along with providers within modules and inheritance.
2021-02-18 11:47:11 -05:00
Alisdair McDiarmid c0b22007fc
Merge pull request #27818 from hashicorp/alisdair/unmark-provisioner-config
core: Unmark provisioner config before validation
2021-02-18 11:27:59 -05:00
Pam Selle 9de4f472f6
Update CHANGELOG.md 2021-02-18 11:15:10 -05:00
Pam Selle 1b534eed6b
Update CHANGELOG.md 2021-02-18 11:14:27 -05:00
Pam Selle 8d2fbd4cd8
Remove deprecation on undeclared variable, docs, and summary adjustment (#27795)
* Remove deprecation on undeclared variable

Remove deprecation and add docs specific to the behavior around
undeclared variable values

* Limit full warnings to 2 instances, then summary

This way, the third warning is a summary, rather than the fourth
warning being the summary
2021-02-18 11:11:52 -05:00
Alisdair McDiarmid 3f017b4413 core: Unmark provisioner config before validation
Sensitive values in provisioner configuration would cause errors in the
validate phase. We need to unmark these value before serializing the
config value for the provisioner plugin.
2021-02-18 10:41:43 -05:00
James Bardin e417d796a0 don't add duplicate proxy provider nodes
Fix the logic to add proxy provider nodes for implicitly passed in
providers. The missing continue allowed multiple nodes satisfying the
same provider address to be added to the graph. When attaching the
providers to resources, the fist one encountered would be used, which
could change each time the graph was built.
2021-02-18 10:17:56 -05:00
Kristin Laemmert f6505870cc
Mildwonkey/providers interface renaming (#27805)
* providers.Interface: huge renamification

This commit renames a handful of functions in the providers.Interface to
match changes made in protocol v6. The following commit implements this
change across the rest of the codebase; I put this in a separate commit
for ease of reviewing and will squash these together when merging.

One noteworthy detail: protocol v6 removes the config from the
ValidateProviderConfigResponse, since it's never been used. I chose to
leave that in place in the interface until we deprecate support for
protocol v5 entirely.

Note that none of these changes impact current providers using protocol
v5; the protocol is unchanged. Only the translation layer between the
proto and terraform have changed.
2021-02-18 10:13:43 -05:00
Jessica Stenning 24e7a5596b Fix sentence in v0.14 upgrade guide 2021-02-18 14:34:04 +00:00
Kristin Laemmert 2b4e389839
Mildwonkey/nested type format (#27793)
* command/format: check for sensitive NestedTypes

Eventually, the diff formatter will need to be updated to properly
handle NestedTypes, but for now we can let the existing function deal
with them as regular cty.Object-type attributes.

To avoid printing sensitive nested attributes, we will treat any
attribute with at least one sensitive nested attribute as an entirely
sensitive attribute.

* bugfix for Object ImpliedType()

ImpliedType() was returning too early when the given object had optional
attributes, therefore skipping the incredibly important step of
accounting for the nesting mode when returning said type.
2021-02-18 08:48:52 -05:00
Alisdair McDiarmid 1d0414a63a
Merge pull request #27813 from hashicorp/paddy_empty_diags
Test empty diagnostics.
2021-02-18 08:22:10 -05:00
Paddy Carver 6c57395ef3 Test empty diagnostics.
Add a test for a diagnostic with no steps to make sure it still gets
associated with the resource in the config. Follow up to #27710 using
@alisdair's suggested testing.
2021-02-18 02:08:10 -08:00
Matthew Frahry 31387d2a0b
Update changelog for #26561 2021-02-17 15:15:55 -08:00
Matthew Frahry 85b9bdea96
backend/azure: azure state refreshes outside of grabbing the lock #26561 2021-02-17 15:14:47 -08:00
Pam Selle 48bfde2e28
Merge pull request #27798 from hashicorp/pselle/upgrade_command_removal
Remove removed `upgrade` commands
2021-02-17 14:42:33 -05:00
Pam Selle 08b649b6f9 Remove removed upgrade commands
Delete commands that are no longer in Terraform and have been
removed for a full release cycle.
2021-02-17 14:34:58 -05:00
James Bardin 04b5c7d452
Merge pull request #27800 from amslezak/patch-1
sentence refactor - consistently -> consistency
2021-02-17 09:02:20 -05:00
James Bardin 2b1dc1ef0d
Merge pull request #27517 from njuCZ/fix_functions_tc
fix test case on windows
2021-02-17 09:00:07 -05:00
James Bardin b0094dbf36
Merge pull request #27678 from GreenHedgehog/master
Fix possible nil pointer dereference in azure sdk
2021-02-17 08:49:49 -05:00
Matthew Frahry d89c8f5dcf
Update changelog for #26721 2021-02-16 23:27:09 -08:00
Matthew Frahry 81dc028689
backend/azurerm: updating the dependencies for the Azure Backend #26721 2021-02-16 23:24:56 -08:00
Andy Slezak 0639054683
sentence refactor - consistently -> consistency 2021-02-16 18:29:31 -05:00
Pam Selle d390fad487
Merge pull request #27799 from hashicorp/pselle/fix_test
[tests] Remove duplicate declaration
2021-02-16 18:17:11 -05:00
Pam Selle b582b19359 Remove duplicate declaration 2021-02-16 18:08:36 -05:00
Alisdair McDiarmid 6375c6ce6b
Merge pull request #27787 from hashicorp/alisdair/command-views-state-locker
clistate: Update clistate.Locker for command views
2021-02-16 17:37:18 -05:00
James Bardin 5b36b37b82
Merge pull request #27758 from hashicorp/jbardin/configuration_aliases-docs
update docs for configuration_aliases
2021-02-16 17:35:24 -05:00
Alisdair McDiarmid bfe791d074
Update CHANGELOG.md 2021-02-16 17:28:20 -05:00
Alisdair McDiarmid f7dbb1ab33
Merge pull request #27796 from hashicorp/alisdair/fix-missing-deposed-key-preapply
terraform: Fix missing deposed key for PreApply
2021-02-16 17:26:24 -05:00
Alisdair McDiarmid 8fb319bc79
Merge pull request #27790 from hashicorp/alisdair/ui-hook-miscolored
cli: Fix misapplied terminal colors on run logs
2021-02-16 17:15:53 -05:00
Alisdair McDiarmid f1a292652d terraform: Fix missing deposed key for PreApply
The PreApply hook was always being called with a nil generation
argument, instead of the deposed key of the resource (if present). This
commit passes the deposed key from the change to the PreApply hook, and
adds a context test to cover this.
2021-02-16 17:14:52 -05:00
James Bardin 0d63b3ec24
Merge pull request #27791 from hashicorp/jbardin/test-conformance-dynamic
reverse call to TestConformance in objchange
2021-02-16 15:42:12 -05:00
Alisdair McDiarmid 0aa227e0e3 cli: Fix misapplied terminal colors on run logs
Due to calling the Colorize function with the full string instead of the
format string, plan/apply logs which include resource instance keys or
IDs which happen to match color formatting would be rendered
incorrectly.

This commit fixes this by only colorizing the known-safe format string.
We also add full test coverage for the UI hook, although only one of the
hooks is tested for this color bugfix due to verbosity of the test.

We also add the bold coloring to the provisioner output prefix, which
seems to have been an oversight.
2021-02-16 15:05:22 -05:00
Kristin Laemmert 7943312ebd
Merge pull request #27699 from hashicorp/mildwonkey/protocolv6
Mildwonkey/protocolv6
2021-02-16 14:51:53 -05:00
Alisdair McDiarmid 1bda146676
Remove changelog entry for backported PR
This is now shipping in 0.14.7
2021-02-16 14:42:11 -05:00
James Bardin 22f21db229 reverse call to TestConformance in objchange
The call to TestConformance needs to be reversed, since we want to
verify that the actual value returned conforms to the planned type.
While the inverse (checking that the planned value conforms to the
applied type) works for everything terraform has been exposed to up
until now, this fails when the planned type has dynamic attributes which
are allowed to become concrete types.
2021-02-16 12:55:02 -05:00
Alisdair McDiarmid 1ae3d30383
Merge pull request #27760 from hashicorp/alisdair/command-views-ui-hook
cli: Migrate Terraform UI hook to command views
2021-02-16 09:36:47 -05:00
Alisdair McDiarmid 20cb28b25f
Merge pull request #27788 from hashicorp/alisdair/command-views-output-tests
views: Expand test coverage for views.Output
2021-02-16 09:07:18 -05:00
Alisdair McDiarmid 1301e38caa
Merge pull request #27786 from hashicorp/alisdair/refresh-empty-diag
backend/local: Return diag for refresh empty state
2021-02-16 09:05:50 -05:00
Alisdair McDiarmid bb3f59b016
Merge pull request #27697 from hashicorp/alisdair/json-plan-provider-required-versions
cli: Fix for missing provider requirements in JSON plan
2021-02-16 09:05:14 -05:00
Alisdair McDiarmid 96cf29111d views: Expand test coverage for views.Output
Now that the view code is separated, we can increase test coverage in
unit tests. This commit moves some tests from the command package which
were testing only view code, and adds more new test cases.
2021-02-16 08:48:31 -05:00
Alisdair McDiarmid 3257f31aa7 backend/local: Return diag for refresh empty state
The warning diag added when refreshing an empty state file was never
rendered, and instead a custom (and incorrect) warning was output to the
UI. This commit fixes the dropped diag and removes the custom warning.
2021-02-16 07:23:31 -05:00
Alisdair McDiarmid 2d1976bbda clistate: Update clistate.Locker for command views
The clistate package includes a Locker interface which provides a simple
way for the local backend to lock and unlock state, while providing
feedback to the user if there is a delay while waiting for the lock.
Prior to this commit, the backend was responsible for initializing the
Locker, passing through direct access to the cli.Ui instance.

This structure prevented commands from implementing different
implementations of the state locker UI. In this commit, we:

- Move the responsibility of creating the appropriate Locker to the
  source of the Operation;
- Add the ability to set the context for a Locker via a WithContext
  method;
- Replace the Locker's cli.Ui and Colorize members with a StateLocker
  view;
- Implement views.StateLocker for human-readable UI;
- Update the Locker interface to return detailed diagnostics instead of
  errors, reducing its direct interactions with UI;
- Add a Timeout() method on Locker to allow the remote backend to
  continue to misuse the -lock-timeout flag to cancel pending runs.

When an Operation is created, the StateLocker field must now be
populated with an implementation of Locker. For situations where locking
is disabled, this can be a no-op locker.

This change has no significant effect on the operation of Terraform,
with the exception of slightly different formatting of errors when state
locking or unlocking fails.
2021-02-16 07:19:22 -05:00
Alisdair McDiarmid a7b7cd29fc cli: Migrate Terraform UI hook to command views
Move the code which renders Terraform hook callbacks as UI into the
views package, backed by a views.View instead of a cli.Ui. Update test
setup accordingly.

To allow commands to control this hook, we add a hooks member on the
backend Operation struct. This supersedes the hooks in the Terraform
context, which is not directly controlled by the command logic.

This commit should not change how Terraform works, and is refactoring in
preparation for more changes which move UI code out of the backend.
2021-02-16 07:18:22 -05:00
Alisdair McDiarmid fa774dafc0
Merge pull request #27761 from hashicorp/alisdair/command-views-operation-diagnostics
backend: Add per-operation diagnostic rendering
2021-02-16 07:17:31 -05:00
Matthew Frahry cb041053e9 Merge with master 2021-02-15 14:37:40 -08:00