Commit Graph

337 Commits

Author SHA1 Message Date
Liam Cervante
d31631675b
Add support for Tuples into the structured plan renderer (#32479)
* add support for tuples to the structured plan renderer

* update after latest main changes
2023-01-09 17:39:13 +01:00
Liam Cervante
2d66eee872
Structured Plan Renderer: Address comments raised in previous PRs (#32478)
* Address comments raised in previous PRs

* add doc comments for public types
2023-01-09 17:15:17 +01:00
Liam Cervante
1332d315b6
Structured Plan Renderer: Remove generic interface{} entry point (#32477)
* Remove the single generic point of entry into the differ package

* goimports

* add comment explaining generic function
2023-01-09 16:49:35 +01:00
Liam Cervante
9bc5ded27a
Add support for outputs in the structured renderer (#32426)
* prep for processing the structured run output

* undo unwanted change to a json key

* Add skeleton functions and API for refactored renderer

* goimports

* Fix documentation of the RenderOpts struct

* Add rendering functionality for primitives to the structured renderer

* add test case for override

* Add support for parsing and rendering sensitive values in the renderer

* Add support for unknown/computed values in the structured renderer

* delete missing unit tests

* Add support for object attributes in the structured renderer

* goimports

* Add support for the replace paths data in the structured renderer

* Add support for maps in the structured renderer

* Add support for lists in the structured renderer

* goimports

* Add support for sets in the structured renderer

* goimports

* Add support for blocks in the structured renderer

* goimports

* Add support for outputs in the structured renderer

* fix ordering of blocks

* remove unused test stub

* fix typo
2023-01-09 14:45:35 +01:00
Liam Cervante
05f1764a0d
Add support for blocks in the structured renderer (#32422)
* prep for processing the structured run output

* undo unwanted change to a json key

* Add skeleton functions and API for refactored renderer

* goimports

* Fix documentation of the RenderOpts struct

* Add rendering functionality for primitives to the structured renderer

* add test case for override

* Add support for parsing and rendering sensitive values in the renderer

* Add support for unknown/computed values in the structured renderer

* delete missing unit tests

* Add support for object attributes in the structured renderer

* goimports

* Add support for the replace paths data in the structured renderer

* Add support for maps in the structured renderer

* Add support for lists in the structured renderer

* goimports

* Add support for sets in the structured renderer

* goimports

* Add support for blocks in the structured renderer

* goimports

* fix ordering of blocks

* remove unused test stub
2023-01-09 14:33:01 +01:00
Liam Cervante
69cce3597f
Add support for sets in the structured renderer (#32409)
* prep for processing the structured run output

* undo unwanted change to a json key

* Add skeleton functions and API for refactored renderer

* goimports

* Fix documentation of the RenderOpts struct

* Add rendering functionality for primitives to the structured renderer

* add test case for override

* Add support for parsing and rendering sensitive values in the renderer

* Add support for unknown/computed values in the structured renderer

* delete missing unit tests

* Add support for object attributes in the structured renderer

* goimports

* Add support for the replace paths data in the structured renderer

* Add support for maps in the structured renderer

* Add support for lists in the structured renderer

* goimports

* Add support for sets in the structured renderer

* goimports
2023-01-09 14:17:30 +01:00
Liam Cervante
aff94591c1
Add support for lists in the structured renderer (#32401)
* prep for processing the structured run output

* undo unwanted change to a json key

* Add skeleton functions and API for refactored renderer

* goimports

* Fix documentation of the RenderOpts struct

* Add rendering functionality for primitives to the structured renderer

* add test case for override

* Add support for parsing and rendering sensitive values in the renderer

* Add support for unknown/computed values in the structured renderer

* delete missing unit tests

* Add support for object attributes in the structured renderer

* goimports

* Add support for the replace paths data in the structured renderer

* Add support for maps in the structured renderer

* Add support for lists in the structured renderer

* goimports

* add additional comments explaining
2023-01-09 14:06:38 +01:00
Liam Cervante
8975eebf84
Add support for maps in the structured renderer (#32397)
* prep for processing the structured run output

* undo unwanted change to a json key

* Add skeleton functions and API for refactored renderer

* goimports

* Fix documentation of the RenderOpts struct

* Add rendering functionality for primitives to the structured renderer

* add test case for override

* Add support for parsing and rendering sensitive values in the renderer

* Add support for unknown/computed values in the structured renderer

* delete missing unit tests

* Add support for object attributes in the structured renderer

* goimports

* Add support for the replace paths data in the structured renderer

* Add support for maps in the structured renderer
2023-01-09 12:41:24 +01:00
Liam Cervante
b097d8873d
Add support for the replace paths data in the structured renderer (#32392)
* prep for processing the structured run output

* undo unwanted change to a json key

* Add skeleton functions and API for refactored renderer

* goimports

* Fix documentation of the RenderOpts struct

* Add rendering functionality for primitives to the structured renderer

* add test case for override

* Add support for parsing and rendering sensitive values in the renderer

* Add support for unknown/computed values in the structured renderer

* delete missing unit tests

* Add support for object attributes in the structured renderer

* goimports

* Add support for the replace paths data in the structured renderer
2023-01-09 12:27:36 +01:00
Liam Cervante
1eebcf875f
Add support for object attributes in the structured renderer (#32391)
* prep for processing the structured run output

* undo unwanted change to a json key

* Add skeleton functions and API for refactored renderer

* goimports

* Fix documentation of the RenderOpts struct

* Add rendering functionality for primitives to the structured renderer

* add test case for override

* Add support for parsing and rendering sensitive values in the renderer

* Add support for unknown/computed values in the structured renderer

* delete missing unit tests

* Add support for object attributes in the structured renderer

* goimports
2023-01-09 12:15:38 +01:00
Liam Cervante
b8b1a8d430
Add support for unknown/computed values in the structured renderer (#32378)
* prep for processing the structured run output

* undo unwanted change to a json key

* Add skeleton functions and API for refactored renderer

* goimports

* Fix documentation of the RenderOpts struct

* Add rendering functionality for primitives to the structured renderer

* add test case for override

* Add support for parsing and rendering sensitive values in the renderer

* Add support for unknown/computed values in the structured renderer

* delete missing unit tests
2023-01-09 11:55:55 +01:00
Liam Cervante
6ab277f6ba
Add support for sensitive values in the structured renderer (#32375)
* prep for processing the structured run output

* undo unwanted change to a json key

* Add skeleton functions and API for refactored renderer

* goimports

* Fix documentation of the RenderOpts struct

* Add rendering functionality for primitives to the structured renderer

* add test case for override

* Add support for parsing and rendering sensitive values in the renderer
2023-01-09 11:40:47 +01:00
Liam Cervante
71daef058f
Add rendering functionality for primitives to the structured renderer (#32373)
* prep for processing the structured run output

* undo unwanted change to a json key

* Add skeleton functions and API for refactored renderer

* goimports

* Fix documentation of the RenderOpts struct

* Add rendering functionality for primitives to the structured renderer

* add test case for override

* goimports
2023-01-09 11:24:01 +01:00
Liam Cervante
aff7d360e1
Add skeleton functions and API for refactored renderer (#32368)
* prep for processing the structured run output

* undo unwanted change to a json key

* Add skeleton functions and API for refactored renderer

* goimports

* Fix documentation of the RenderOpts struct

* Add README explaining implementation details for renderer and plans for future expansion

* Update internal/command/jsonformat/README.md

Co-authored-by: Alisdair McDiarmid <alisdair@users.noreply.github.com>

* address comments

Co-authored-by: Alisdair McDiarmid <alisdair@users.noreply.github.com>
2023-01-09 11:05:25 +01:00
Liam Cervante
b917154a97
Make required JSON structured output structures public for processing (#32367)
* prep for processing the structured run output

* undo unwanted change to a json key
2023-01-09 10:48:23 +01:00
James Bardin
721df0e68d
Merge pull request #32395 from hashicorp/jbardin/plan-output-on-error
Always show and store planned actions and checks even when planning fails
2023-01-04 12:44:52 -05:00
James Bardin
a6098b67fa fix test state 2022-12-21 10:47:07 -05:00
James Bardin
25ac4d33e4
Merge pull request #31633 from brittandeyoung/f-workspace-selectornew
New Terraform Workspace select flag: `-or-create`
2022-12-16 15:29:25 -05:00
Brittan DeYoung
8881418c99
Update internal/command/workspace_select.go
Co-authored-by: James Bardin <j.bardin@gmail.com>
2022-12-16 15:03:46 -05:00
James Bardin
d60d247e40
Merge pull request #31318 from twittyc/twittyc/terraformWorkspaceInvalidArgsReturnsNon0
Bug fix: Terraform workspace command returns zero exit code when given an invalid argument.
2022-12-16 13:16:56 -05:00
James Bardin
76d5e4a9cb add command test for errored plan 2022-12-14 16:23:31 -05:00
James Bardin
5aa088e385 remove -always-out
Make writing a plan file the default. We already create plans which have
no changes so the plan result would need to be checked in automation, so
having plans with errors should not pose a problem.

If we find workflows which cannot handle a plan that can't be applied,
we can reevaluate the need for a specialized flag. In the meantime, it
feels more logical that the plan output would always describe the result
of the plan, even if that included errors.
2022-12-14 11:09:34 -05:00
Martin Atkins
4660dacd59 command: Prototype of handling errored plans
This is a prototype of how the CLI layer might make use of Terraform
Core's ability to produce a partial plan if it encounters an error during
planning, with two new situations:

- When using local CLI workflow, Terraform will show the partial plan
  before showing any errors.
- "terraform plan" has a new option -always-out=..., which is similar to
  the existing -out=... but additionally instructs Terraform to produce
  a plan file even if the plan is incomplete due to errors. This means
  that the plan can still be inspected by external UI implementations.

This is just a prototype to explore how these parts might fit together.
It's not a complete implementation and so should not be shipped. In
particular, it doesn't include any mention of a plan being incomplete in
the "terraform show -json" output or in the "terraform plan -json" output,
both of which would be required for a complete solution.
2022-12-12 17:17:42 -05:00
James Bardin
404b284911
Merge pull request #31757 from hashicorp/jbardin/terraform-data
New `terraform_data` managed resource to replace `null_resource`
2022-12-12 15:17:02 -05:00
Conor Evans
e206d4e83e
fix(unlock): amend force-unlock description (#32363)
Signed-off-by: Conor Evans <coevans@tcd.ie>

Signed-off-by: Conor Evans <coevans@tcd.ie>
2022-12-09 16:15:27 +00:00
James Bardin
d0d6501c1f s/trigger/triggers_replace/
Rename `triggers` to be more descriptive, making it similar to
`replace_triggered_by`.
2022-12-05 15:23:57 -05:00
James Bardin
58e15c7f0e add terraform_data e2e test 2022-12-05 15:23:57 -05:00
alisdair
ec6451a82a
Merge pull request #31999 from JarrettSpiker/jspiker/workspace-delete-rum-docs
Update workspace delete command docs to reference RUM vs empty state
2022-11-25 12:07:02 -05:00
Jarrett Spiker
21d98697cb Add manual line breaks to workspace delete command help text 2022-11-25 11:42:22 -05:00
Jarrett Spiker
060255a9d5 Use safe or force workspace delete for cloud backend 2022-11-21 14:35:33 -05:00
Martin Atkins
d0a35c60a7 providercache: Ignore lock-mismatching global cache entries
When we originally introduced the trust-on-first-use checksum locking
mechanism in v0.14, we had to make some tricky decisions about how it
should interact with the pre-existing optional read-through global cache
of provider packages:

The global cache essentially conflicts with the checksum locking because
if the needed provider is already in the cache then Terraform skips
installing the provider from upstream and therefore misses the opportunity
to capture the signed checksums published by the provider developer. We
can't use the signed checksums to verify a cache entry because the origin
registry protocol is still using the legacy ziphash scheme and that is
only usable for the original zipped provider packages and not for the
unpacked-layout cache directory. Therefore we decided to prioritize the
existing cache directory behavior at the expense of the lock file behavior,
making Terraform produce an incomplete lock file in that case.

Now that we've had some real-world experience with the lock file mechanism,
we can see that the chosen compromise was not ideal because it causes
"terraform init" to behave significantly differently in its lock file
update behavior depending on whether or not a particular provider is
already cached. By robbing Terraform of its opportunity to fetch the
official checksums, Terraform must generate a lock file that is inherently
non-portable, which is problematic for any team which works with the same
Terraform configuration on multiple different platforms.

This change addresses that problem by essentially flipping the decision so
that we'll prioritize the lock file behavior over the provider cache
behavior. Now a global cache entry is eligible for use if and only if the
lock file already contains a checksum that matches the cache entry. This
means that the first time a particular configuration sees a new provider
it will always be fetched from the configured installation source
(typically the origin registry) and record the checksums from that source.

On subsequent installs of the same provider version already locked,
Terraform will then consider the cache entry to be eligible and skip
re-downloading the same package.

This intentionally makes the global cache mechanism subordinate to the
lock file mechanism: the lock file must be populated in order for the
global cache to be effective. For those who have many separate
configurations which all refer to the same provider version, they will
need to re-download the provider once for each configuration in order to
gather the information needed to populate the lock file, whereas before
they would have only downloaded it for the _first_ configuration using
that provider.

This should therefore remove the most significant cause of folks ending
up with incomplete lock files that don't work for colleagues using other
platforms, and the expense of bypassing the cache for the first use of
each new package with each new configuration. This tradeoff seems
reasonable because otherwise such users would inevitably need to run
"terraform providers lock" separately anyway, and that command _always_
bypasses the cache. Although this change does decrease the hit rate of the
cache, if we subtract the never-cached downloads caused by
"terraform providers lock" then this is a net benefit overall, and does
the right thing by default without the need to run a separate command.
2022-11-04 16:18:15 -07:00
Brandon Croft
bd744ad4e9
Unify all sensitive value plan output as "(sensitive value)"
Previously, there was mixed usage of "(sensitive)" and "(sensitive value)" and even though it was more common to see "(sensitive)", the thought is that it's a value we are hiding rather than describing something already shown.
2022-10-24 12:50:46 -06:00
Brandon Croft
076fccd8e7
fix: don't reveal nested attributes with sensitive schema 2022-10-24 12:50:46 -06:00
Jarrett Spiker
3d5dba5c09
Update internal/command/workspace_delete.go
Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>
2022-10-17 11:52:24 -04:00
Jarrett Spiker
9d2e8a4c7e Update workspace delete command docs and help to reference RUM instead of non-empty state 2022-10-11 15:51:17 -04:00
UKEME BASSEY
7b34e3e743 redact sensitive output values in run logs 2022-09-22 13:47:47 -04:00
Megan Bang
72ba8a869e removes EnableForcePush and other unrelated code 2022-09-02 14:49:25 -05:00
Brittan DeYoung
11da5afb5e Spelling Error fixes 2022-08-31 15:13:15 -04:00
Brittan DeYoung
409bd667c3 workspace: update envDoesNotExist message 2022-08-31 13:36:31 -04:00
Brittan DeYoung
7110ec8b0c select: Fix capitalization of help text 2022-08-31 13:29:31 -04:00
Brittan DeYoung
7d0d352eed select: -or-create helptext and conditional output 2022-08-31 13:28:28 -04:00
Brittan DeYoung
5932540be3 New Terraform Workspace select flag: 2022-08-31 13:07:18 -04:00
kmoe
ba113ff2cd
add destroy option to terraform apply help text (#31714) 2022-08-31 15:13:26 +01:00
megan07
cb340207d8
Merge pull request #31698 from hashicorp/megan_tf563
Send the JSON state representation to Cloud backend (when available)
2022-08-30 18:10:45 -05:00
Megan Bang
37b7e6ebce don't check diags for errors 2022-08-30 18:03:57 -05:00
Megan Bang
4d749e2813 add warning to diags and show at the end of each command 2022-08-30 17:52:51 -05:00
Megan Bang
5eaa4c45c0 fix imports 2022-08-30 17:27:15 -05:00
Megan Bang
de8bd5826f first part of code review comments 2022-08-30 17:01:44 -05:00
kmoe
dec48a8510
plans: indicate when resource deleted due to move (#31695)
Add a new ChangeReason, ReasonDeleteBecauseNoMoveTarget, to provide better
information in cases where a planned deletion is due to moving a resource to
a target not in configuration.

Consider a case in which a resource instance exists in state at address A, and
the user adds a moved block to move A to address B. Whether by the user's
intention or not, address B does not exist in configuration.
Terraform combines the move from A to B, and the lack of configuration for B,
into a single delete action for the (previously nonexistent) entity B.
Prior to this commit, the Terraform plan will report that resource B will be
destroyed because it does not exist in configuration, without explicitly
connecting this to the move.

This commit provides the user an additional clue as to what has happened, in a
case in which Terraform has elided a user's action and inaction into one
potentially destructive change.
2022-08-30 18:01:29 +01:00
Megan Bang
b504dd1489 update from code consistency checks 2022-08-29 14:29:07 -05:00