Commit Graph

29591 Commits

Author SHA1 Message Date
Drew Hodun a26b551d47 added github.com commit reference example 2022-02-22 11:09:22 -05:00
Alisdair McDiarmid 17492285f4
Merge pull request #30561 from hashicorp/alisdair/json-output-optimization
jsonplan: Improve performance for deep objects
2022-02-22 10:12:00 -05:00
Alisdair McDiarmid 3e4d6b252f jsonplan: Improve performance for deep objects
When calculating the unknown values for JSON plan output, we would
previously recursively call the `unknownAsBool` function on the current
sub-tree twice, if any values were unknown. This was wasteful, but not
noticeable for normal Terraform resource shapes.

However for deeper nested object values, such as Kubernetes manifests,
this was a severe performance problem, causing `terraform show -json` to
take several hours to render a plan.

This commit reuses the already calculated unknown value for the subtree,
and adds benchmark coverage to demonstrate the improvement.
2022-02-18 17:00:18 -05:00
nozaq 3c32f7a56c
jsonconfig: add implicitly created provider configs 2022-02-19 01:55:09 +09:00
nozaq 0ce040405c
jsonconfig: fix provider mappings with same names 2022-02-19 00:44:48 +09:00
kmoe 161374725c
Warn when ignore_changes includes a Computed attribute (#30517)
* ignore_changes attributes must exist in schema

Add a test verifying that attempting to add a nonexistent attribute to
ignore_changes throws an error.

* ignore_changes cannot be used with Computed attrs

Return a warning if a Computed attribute is present in ignore_changes,
unless the attribute is also Optional.

ignore_changes on a non-Optional Computed attribute is a no-op, so the user
likely did not want to set this in config.
An Optional Computed attribute, however, is still subject to ignore_changes
behaviour, since it is possible to make changes in the configuration that
Terraform must ignore.
2022-02-18 10:38:29 +00:00
nozaq 7f4019e1f6
jsonconfig: fix keys for default providers
Fixes provider config keys to reflect implicit provider inheritance.
2022-02-16 01:38:57 +09:00
Laura Pacilio 68e70d71d4
Merge pull request #30483 from bpar476/patch-1
Adds documentation to `substr` function to cover when `length` exceeds input length
2022-02-15 11:27:47 -05:00
Ben Partridge 252865c6a0
Improvements to wording of substr function documentation
Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>
2022-02-15 10:23:37 +11:00
Pedro Belém aed7162e9a
cli: Fix state mv exit code for missing resource (#29839) 2022-02-14 15:20:03 -05:00
Alisdair McDiarmid 7a20c07cb0
Update CHANGELOG.md 2022-02-10 10:35:34 -05:00
Alisdair McDiarmid d8018270a7
Merge pull request #30138 from hashicorp/alisdair/json-module-call-providers-mapping
jsonconfig: Improve provider configuration output
2022-02-10 10:33:47 -05:00
Alisdair McDiarmid 0a9503812d
Merge pull request #30476 from hashicorp/alisdair/fix-type-marks
cli: Prevent complex uses of the console-only `type` function
2022-02-10 10:23:07 -05:00
Alisdair McDiarmid 98f80bc5da website: Explain limitations of type function 2022-02-10 06:12:58 -05:00
Alisdair McDiarmid 843c50e8ce lang: Further limit the console-only type function
This commit introduces a capsule type, `TypeType`, which is used to
extricate type information from the console-only `type` function. In
combination with the `TypeType` mark, this allows us to restrict the use
of this function to top-level display of a value's type. Any other use
of `type()` will result in an error diagnostic.
2022-02-10 06:12:58 -05:00
Laura Pacilio c5740baa77
Merge pull request #30503 from hashicorp/fix-workspace-name-docs
Clarify workspace.name expression
2022-02-09 17:47:13 -05:00
Alisdair McDiarmid 903d6f1055 lang: Remove use of marks.Raw in tests
These instances of marks.Raw usage were semantically only testing the
properties of combining multiple marks. Testing this with an arbitrary
value for the mark is just as valid and clearer.
2022-02-09 17:43:54 -05:00
Alisdair McDiarmid 691b98b612 cli: Prevent overuse of console-only type function
The console-only `type` function allows interrogation of any value's
type.  An implementation quirk is that we use a cty.Mark to allow the
console to display this type information without the usual HCL quoting.
For example:

> type("boop")
string

instead of:

> type("boop")
"string"

Because these marks can propagate when used in complex expressions,
using the type function as part of a complex expression could result in
this "print as raw" mark being attached to a collection. When this
happened, it would result in a crash when we tried to iterate over a
marked value.

The `type` function was never intended to be used in this way, which is
why its use is limited to the console command. Its purpose was as a
pseudo-builtin, used only at the top level to display the type of a
given value.

This commit goes some way to preventing the use of the `type` function
in complex expressions, by refusing to display any non-string value
which was marked by `type`, or contains a sub-value which was so marked.
2022-02-09 17:43:54 -05:00
Laura Pacilio 24cffb5ff3 Soften language for determining run environment 2022-02-09 17:41:12 -05:00
Laura Pacilio 422b47618c Change name example to match new edits 2022-02-09 17:37:06 -05:00
Laura Pacilio 8be2c4a397 fix link 2022-02-09 14:30:02 -05:00
Laura Pacilio faffa11e08 Update workspaces page 2022-02-09 14:21:46 -05:00
Laura Pacilio ba0e2c1133 Update remote backend page to clarify workspace.name expression 2022-02-09 14:10:11 -05:00
Laura Pacilio c1dc94a3d2
Merge pull request #30488 from hashicorp/update-console-docs
Update Console Command Documentation
2022-02-08 16:36:36 -05:00
Laura Pacilio 3c40dac0bc Fix according to PR comments 2022-02-08 16:22:44 -05:00
Craig Wright 3af6e82463
Merge pull request #30485 from salob/patch-1
Removing unnecessary comma from a single entry list example.
2022-02-08 11:59:44 -08:00
Laura Pacilio b6dd327fd3
Merge pull request #30487 from hashicorp/update-depends-on-docs
Update depends_on documentation
2022-02-07 18:52:57 -05:00
Laura Pacilio fe6092f325 Add line about how you can't use console during a run 2022-02-07 18:45:07 -05:00
Laura Pacilio 7eee8c674e Remove extra spaces 2022-02-07 18:16:16 -05:00
Laura Pacilio 879edcae72 wording changes 2022-02-07 18:09:07 -05:00
Alisdair McDiarmid fe8183c4af json: Increment JSON plan format version
The JSON plan configuration data now includes a `full_name` field for
providers. This addition warrants a backwards compatible increment to
the version number.
2022-02-07 15:06:05 -05:00
Alisdair McDiarmid ddc81a204f json: Disregard format version in tests
Instead of manually updating every JSON output test fixture when we
change the format version, disregard any differences when testing.
2022-02-07 15:05:58 -05:00
Alisdair McDiarmid f5b90f84a8 jsonconfig: Improve provider configuration output
When rendering configuration as JSON, we have a single map of provider
configurations at the top level, since these are globally applicable.
Each resource has an opaque key into this map which points at the
configuration data for the provider.

This commit fixes two bugs in this implementation:

- Resources in non-root modules had an invalid provider config key,
  which meant that there was never a valid reference to the provider
  config block. These keys were prefixed with the local module name
  instead of the path to the module. This is now corrected.

- Modules with passed provider configs would point to either an empty
  provider config block or one which is not present at all. This has
  been fixed so that these resources point to the provider config block
  from the calling module (or wherever up the module tree it was
  originally defined).

We also add a "full_name" key-value pair to the provider config block,
with the entire fully-qualified provider name including hostname and
namespace.
2022-02-07 15:05:58 -05:00
Laura Pacilio 2a3b0f9c1e
Merge pull request #30017 from RubyElders/internal-contributing-docs
Update go test commands in .github/CONTRIBUTING.md.
2022-02-07 14:23:52 -05:00
Laura Pacilio dbc143a043
Merge pull request #30484 from hashicorp/fix-preconditions
Preconditions and Postconditions - Quick Fixes
2022-02-07 13:19:24 -05:00
sian d81335a55e
delete comma from single entry list 2022-02-07 18:12:26 +00:00
Laura Pacilio 6e399dfbe0 Update filename 2022-02-07 12:04:50 -05:00
Laura Pacilio 834f65e4f0 Fix formatting issues that would prevent website from loading 2022-02-07 11:59:28 -05:00
Ben Partridge fa8a87fab5
Adds documentation to `substr` function to cover when `length` longer than input `string`
The `substr` function allows the `length` parameter to be longer than the remaining characters in the input after the offset. This is useful for when you want to truncate a string to a maximum number of characters. However, the documentation isn't clear on this so I had to do a test deployment to confirm the behaviour after finding the behaviour in an old issue https://github.com/hashicorp/terraform/issues/15751
2022-02-07 15:12:22 +11:00
Alisdair McDiarmid d1ac8b71d4
Merge pull request #30471 from hashicorp/alisdair/what-even-is-validate
core: Remove unused PlanOpts.Validate
2022-02-04 08:21:09 -05:00
Alisdair McDiarmid 639eb5212f core: Remove unused PlanOpts.Validate
This vestigial field was written to but never read.
2022-02-03 14:16:25 -05:00
Alisdair McDiarmid eea706aaef
Merge pull request #30462 from hashicorp/alisdair/preconditions-postconditions-self-references
configs: Validate pre/postcondition self-refs
2022-02-03 10:11:40 -05:00
Alisdair McDiarmid 7ded73f266 configs: Validate pre/postcondition self-refs
Preconditions and postconditions for resources and data sources may not
refer to the address of the containing resource or data source. This
commit adds a parse-time validation for this rule.
2022-02-03 09:37:22 -05:00
Alisdair McDiarmid 013170dd1b
Update CHANGELOG.md 2022-02-02 15:45:14 -05:00
Alisdair McDiarmid 0634c9437a
Merge pull request #30401 from hashicorp/f-preconditions-postconditions-rebased
Preconditions and Postconditions
2022-02-02 15:31:03 -05:00
Laura Pacilio d3bc3a63dd
Merge pull request #30431 from hashicorp/replace-flag-clarifications
Make -replace flag clearer
2022-02-01 10:47:04 -05:00
Alisdair McDiarmid cdae6d4396 core: Add context tests for pre/post conditions 2022-01-31 15:38:26 -05:00
Alisdair McDiarmid a95ad997e1 core: Document postconditions as valid use of self
This is not currently gated by the experiment only because it is awkward
to do so in the context of evaluationStateData, which doesn't have any
concept of experiments at the moment.
2022-01-31 14:34:35 -05:00
Laura Pacilio a794c80e0d final nits 2022-01-31 14:17:36 -05:00
Laura Pacilio d14e04bf36 Fix notes according to PR feedback 2022-01-31 14:03:03 -05:00