Commit Graph

30169 Commits

Author SHA1 Message Date
hc-github-team-tf-core
2f1a8bbbd8 Cleanup after v1.3.0-alpha20220608 release 2022-06-08 17:31:07 +00:00
hc-github-team-tf-core
da14009ef0
Release v1.3.0-alpha20220608 2022-06-08 17:15:04 +00:00
Laura Pacilio
29435b46ac Edit type constraints docs for style and flow 2022-06-08 12:40:29 -04:00
Laura Pacilio
5bfd746696
Merge pull request #31198 from hashicorp/add-format-function-guidance
Add guidance about using the format function
2022-06-08 11:08:53 -04:00
Park Choong Ho
3513352300
Update syntax.mdx
fix wrong grammar
2022-06-08 18:37:56 +09:00
Laura Pacilio
6aa960c239
Update website/docs/language/expressions/custom-conditions.mdx 2022-06-07 17:09:42 -04:00
Laura Pacilio
9b57fc2964 Add guidance about using the format function 2022-06-07 16:44:25 -04:00
Laura Pacilio
e5658c2478 Explain the the destroy mode is the same as running terraform destroy 2022-06-07 15:27:00 -04:00
Laura Pacilio
3c2685222e Update apply page for style, concision, and clarity 2022-06-07 15:21:40 -04:00
Laura Pacilio
41659a776e
Merge pull request #31185 from paullschock/patch-2
Add details reg. verbosity of debug log level (replace #29641)
2022-06-06 12:25:10 -04:00
Ignacio Miranda Figueroa
68a83e48e7
docs: update depends_on.mdx meta-argument 2022-06-06 11:15:09 -04:00
Alisdair McDiarmid
6c3d50e37f
Update CHANGELOG.md 2022-06-06 11:08:19 -04:00
Alisdair McDiarmid
f8e2b3ada5
Merge pull request #31154 from hashicorp/alisdair/module-variable-optional-default
Add inline defaults to optional object attribute type constraints
2022-06-06 11:06:43 -04:00
James Bardin
82f47ca992
Merge pull request #31184 from hashicorp/bflad-GetProviderSchema-early-diag-return
Return early on GetProviderSchema RPC responses with error diagnostics
2022-06-06 09:00:59 -04:00
Paul Schock
48b06007dd
Add details reg. verbosity of debug log level
Update as a result of https://github.com/hashicorp/terraform/pull/29641
2022-06-03 12:17:52 -07:00
Brian Flad
0b404f4a95 Return early on GetProviderSchema RPC responses with error diagnostics
Reference: https://github.com/hashicorp/terraform/issues/31047

Prevent potential panics and immediately return provider-defined errors diagnostics.

Previously:

```
--- FAIL: TestGRPCProvider_GetSchema_ResponseErrorDiagnostic (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x70 pc=0x17fa752]

goroutine 13 [running]:
testing.tRunner.func1.2({0x191a100, 0x2236330})
	/usr/local/Cellar/go/1.18.2/libexec/src/testing/testing.go:1389 +0x24e
testing.tRunner.func1()
	/usr/local/Cellar/go/1.18.2/libexec/src/testing/testing.go:1392 +0x39f
panic({0x191a100, 0x2236330})
	/usr/local/Cellar/go/1.18.2/libexec/src/runtime/panic.go:838 +0x207
github.com/hashicorp/terraform/internal/plugin6/convert.ProtoToConfigSchema(0x0)
	/Users/bflad/src/github.com/hashicorp/terraform/internal/plugin6/convert/schema.go:110 +0x52
github.com/hashicorp/terraform/internal/plugin6/convert.ProtoToProviderSchema(...)
	/Users/bflad/src/github.com/hashicorp/terraform/internal/plugin6/convert/schema.go:98
github.com/hashicorp/terraform/internal/plugin6.(*GRPCProvider).GetProviderSchema(0xc00004a200)
	/Users/bflad/src/github.com/hashicorp/terraform/internal/plugin6/grpc_provider.go:152 +0x29a
github.com/hashicorp/terraform/internal/plugin6.TestGRPCProvider_GetSchema_ResponseErrorDiagnostic(0x0?)
	/Users/bflad/src/github.com/hashicorp/terraform/internal/plugin6/grpc_provider_test.go:158 +0x265
testing.tRunner(0xc0001031e0, 0x1a733d8)
	/usr/local/Cellar/go/1.18.2/libexec/src/testing/testing.go:1439 +0x102
created by testing.(*T).Run
	/usr/local/Cellar/go/1.18.2/libexec/src/testing/testing.go:1486 +0x35f
```

Previously:

```
--- FAIL: TestGRPCProvider_GetSchema_ResponseErrorDiagnostic (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x70 pc=0x18a2732]

goroutine 7 [running]:
testing.tRunner.func1.2({0x1a5e720, 0x250be50})
	/usr/local/Cellar/go/1.18.2/libexec/src/testing/testing.go:1389 +0x24e
testing.tRunner.func1()
	/usr/local/Cellar/go/1.18.2/libexec/src/testing/testing.go:1392 +0x39f
panic({0x1a5e720, 0x250be50})
	/usr/local/Cellar/go/1.18.2/libexec/src/runtime/panic.go:838 +0x207
github.com/hashicorp/terraform/internal/plugin/convert.ProtoToConfigSchema(0x0)
	/Users/bflad/src/github.com/hashicorp/terraform/internal/plugin/convert/schema.go:104 +0x52
github.com/hashicorp/terraform/internal/plugin/convert.ProtoToProviderSchema(...)
	/Users/bflad/src/github.com/hashicorp/terraform/internal/plugin/convert/schema.go:92
github.com/hashicorp/terraform/internal/plugin.(*GRPCProvider).GetProviderSchema(0xc00004a600)
	/Users/bflad/src/github.com/hashicorp/terraform/internal/plugin/grpc_provider.go:149 +0x29a
github.com/hashicorp/terraform/internal/plugin.TestGRPCProvider_GetSchema_ResponseErrorDiagnostic(0x0?)
	/Users/bflad/src/github.com/hashicorp/terraform/internal/plugin/grpc_provider_test.go:130 +0x265
testing.tRunner(0xc0001031e0, 0x1be9500)
	/usr/local/Cellar/go/1.18.2/libexec/src/testing/testing.go:1439 +0x102
created by testing.(*T).Run
	/usr/local/Cellar/go/1.18.2/libexec/src/testing/testing.go:1486 +0x35f
```
2022-06-03 14:27:55 -04:00
Alisdair McDiarmid
472df9686f
Update CHANGELOG.md
Removing items which shipped in the recent 1.2 patch release.
2022-06-02 16:47:54 -04:00
Martin Atkins
e00f0804ef development docs: Planning Behaviors
For a while now we've had information equivalent to this in various
internal documents that we've referred to when designing features such as
config-driven refactoring, the "replace" planning option, and so forth.

However, so far we've not put that information in any sort of durable
public place that we can easily find and refer to when having design
discussions on GitHub and similar.

This is therefore an attempt to capture a summary of the three main design
patterns we've identified for planning-related behaviors, with a few
motivating examples of each one, in the hope that this will be a good
reference and some helpful inspiration for future design work.

It's intentionally not totally comprehensive of all planning behaviors
both because that would duplicate the end-user-oriented documentation and
because it would be burdensome to keep updating this document each time we
add anything new which might fit into these categories. However, we might
add a later feature to this document if it illustrates a new take or
different perspective on one of these patterns.
2022-06-02 10:56:29 -07:00
Laura Pacilio
6c7db7186a
Merge pull request #31171 from fractos/patch-1
Fix custom conditions example
2022-06-02 10:59:53 -04:00
James Bardin
619fa61f0b have mockProvider always check it was configured
We do this already for other calls, but skipped UpgradeResourceState
since it wasn't previously possible to configure during a destroy plan.
2022-06-01 16:16:20 -04:00
James Bardin
38d70a1c3d configure providers during destroy plan
Now that we can fully evaluate a provider configuration, make sure we
configure the provider before using it during a destroy plan.
2022-06-01 16:03:27 -04:00
James Bardin
93ff27227a
Merge pull request #31163 from hashicorp/jbardin/plan-destroy
Use plan graph builder for destroy
2022-06-01 15:37:13 -04:00
James Bardin
e36ee757a5 minor cleanup from review 2022-06-01 15:29:59 -04:00
James Bardin
4fb8a5a3ec
Merge pull request #31164 from hashicorp/jbardin/go-getter-security-options
add XTerraformGetLimit to prevent redirect loops
2022-06-01 13:04:20 -04:00
James Bardin
47f9850f02 add XTerraformGetLimit to prevent redirect loops 2022-06-01 12:46:22 -04:00
kmoe
229789f60f
Update CHANGELOG.md 2022-06-01 17:08:02 +01:00
kmoe
f341c35819
Update CHANGELOG.md 2022-06-01 16:00:08 +01:00
Adam Christie
50919044d5
Fix custom conditions example
Original code block erroneously references `aws_vpc.example` but appears to actually mean `data.aws_vpc.example`.
2022-06-01 12:41:15 +01:00
Alisdair McDiarmid
e2a3042025 website: Update documentation for optional attrs
Extend the documentation on type constraints to include the new default
functionality, including a detailed example of a nested structure with
multiple levels of defaults.
2022-06-01 06:40:37 -04:00
Alisdair McDiarmid
718b0875ef lang: Remove defaults function
Now that we are able to specify optional object attribute defaults
inline in a type constraint, the separate `defaults` function is no
longer needed.
2022-06-01 06:40:37 -04:00
Luces Huayhuaca
70ddcc7d0d
add url to summary and check for optional values (#30993) 2022-05-31 13:48:07 -07:00
Alisdair McDiarmid
5b0052cc36 core: Apply type defaults to module variables
Now that variables parse and retain a set of default values for
object attributes, we must apply the defaults during variable
evaluation. We do so immediately before type conversion, preprocessing
the given value so that conversion will receive the intended defaults as
appropriate.
2022-05-31 12:11:15 -04:00
Alisdair McDiarmid
650380f3ae configs: Add default argument to optional()
The optional modifier previously accepted a single argument: the
attribute type. This commit adds an optional second argument, which
specifies a default value for the attribute.

To record the default values for a variable's type, we use a separate
parallel structure of `typeexpr.Defaults`, rather than extending
`cty.Type` to include a `cty.Value` of defaults (which may in turn
include a `cty.Type` with defaults, and so on, and so forth).

The new `typeexpr.TypeConstraintWithDefaults` returns a type constraint
and defaults value. Defaults will be `nil` unless there are default
values specified somewhere in the variable's type.
2022-05-31 12:11:15 -04:00
Alisdair McDiarmid
8f69e36e1b typeexpr: Add support for nested type defaults
In type constraints, object attributes may be marked as optional in
order to allow them to be omitted from input values. Doing so results in
filling the attribute value with a typed `null`.

This commit adds a new type `typeexpr.Defaults` which mirrors the
structure of a type constraint, storing default values for optional
attributes. This will allow specification of non-`null` default values
for attributes.

The `Defaults` type is a tree structure, each node containing a sub-tree
type, a map of children, and for object nodes, a map of defaults. The
keys in the children map depend on the type of the node:

- Object nodes have children for each attribute;
- Tuple nodes have children for each index, with indices converted to
  string values;
- Collection nodes have a single child at the empty string key.

When traversing this tree we must take this structure into account, with
special cases for map input values which may later be converted to
objects.

The traversal defined in this commit uses a pre-order transformer in
order to pre-populate descendent nodes before their defaults are
applied. This allows type nested type default values to be specified
more compactly.
2022-05-31 12:11:15 -04:00
Piggy
367a850989
Bump github.com/Netflix/go-expect (#31103) 2022-05-31 16:24:01 +01:00
kmoe
8f7e03b95b
deps: upgrade mitchellh/cli (#31160) 2022-05-31 16:12:56 +01:00
kmoe
54b837416c
command: mention plan options in refresh help text (#30892)
* command: add parallelism option to refresh help text
2022-05-31 14:27:21 +01:00
Alisdair McDiarmid
a6587970d0
Merge pull request #30552 from gbataille/29156_do_not_log_sensitive_values
Fixes #29156: Failing sensitive variables values are not logged
2022-05-30 10:40:51 -04:00
Alisdair McDiarmid
06f6a901ea
Merge pull request #30985 from hashicorp/alisdair/var-flag-spaces-error
cli: Improved error for invalid -var "foo = bar"
2022-05-30 10:40:00 -04:00
James Bardin
ec476af655 test for configured destroy plan provider 2022-05-27 11:58:25 -04:00
James Bardin
8fed14fc59 use the PlanGraphBuilder for destroy
Rather than maintain a separate graph builder for destroy, use the
normal plan graph with some extra options. Utilize the same pattern as
the validate graph for now, where we take the normal plan graph builder
and inject a new concrete function for the destroy nodes.
2022-05-27 10:59:11 -04:00
James Bardin
77d13808d5 rename field to destroyPlan for consistency 2022-05-27 10:58:28 -04:00
James Bardin
6860596b68 don't add orphan nodes during destroy
All instances in state are being removed for destroy, so we can skip
checking for orphans. Because we want to use the normal plan graph, we
need to be able to still call this during destroy, so flag it off.
2022-05-27 10:56:40 -04:00
James Bardin
d6f0d1ea57 don't add config nodes during destroy plan
We want to use the normal plan graph for destroy, so we need to flag off
configuration for that process.
2022-05-27 10:55:38 -04:00
James Bardin
e3a6e1f6e8 remove unused fields from DestroyEdgeTransformer 2022-05-27 10:54:58 -04:00
James Bardin
b8e362d24c do not connect references _to_ destroyers either
Destroy nodes should never participate in references. These edges didn't
come up before, because we weren't building a complete graph including
all temporary values.
2022-05-27 10:50:01 -04:00
Nick Fagerlund
5bf48952fe
Edit docs for replace_triggered_by lifecycle argument (#31129)
- Note that it was added in v1.2, so users know whether they can use it yet.
- Fix nested indentation formatting, so the parent list item stays together.
- Minor copy edits.
- List all of the available lifecycle block arguments before diving into the
  docs for each argument, for ease of reading/scanning.
2022-05-26 10:39:04 -07:00
James Bardin
903ba7e94e
Merge pull request #31124 from hashicorp/jbardin/go-getter-update
update go-getter
2022-05-25 10:37:57 -04:00
James Bardin
f24eb858c8 update go-getter 2022-05-25 09:19:46 -04:00
Craig Wright
f215e6fc3e
Merge pull request #31121 from cuotos/fix-intentional-typo
Revert "Docs: Change misspelling of variable in documentation"
2022-05-24 11:33:25 -07:00