Commit Graph

30285 Commits

Author SHA1 Message Date
Alisdair McDiarmid
a5f307b5e4
Merge pull request #31293 from dennygursky/main
Performance: string builder speedup for Module.String()
2022-06-23 10:58:35 -04:00
Alisdair McDiarmid
ad52076025 addrs: Add tests for Module.String 2022-06-23 10:42:07 -04:00
hc-github-team-tf-core
1dcfabdba9 Cleanup after v1.3.0-alpha20220622 release 2022-06-22 19:34:49 +00:00
hc-github-team-tf-core
093abf5677
Release v1.3.0-alpha20220622 2022-06-22 19:17:51 +00:00
James Bardin
c43df009db add required attr to import test
Missing required attributes should not prevent importing
2022-06-22 13:30:44 -04:00
Alisdair McDiarmid
5df6bac2f7
Merge pull request #31290 from hashicorp/alisdair/check-block-missing-condition
configs: Fix check block configuration diagnostics
2022-06-22 11:51:46 -04:00
Dennis Gursky
2c1b1f3aa1
Update module.go
making code more similar to https://github.com/hashicorp/terraform/blob/main/internal/addrs/module_instance.go
2022-06-22 06:29:57 -07:00
Denny Gursky
8a694e81ff string builder speed up for Module.String() 2022-06-21 21:49:30 -07:00
Alisdair McDiarmid
64cf53bd7e configs: Fix check block configuration diagnostics
When validating self-references for resource and data source
preconditions and postconditions, we previously did not nil-check the
block's condition field, which caused a panic when the block had no
condition.

While fixing this I noticed that we were not validating that there are
no self-references in the error message, so fixed that.
2022-06-21 12:13:45 -04:00
James Bardin
4981942191 remove -allow-missing-config from import 2022-06-21 11:43:04 -04:00
James Bardin
03fc2b09df remove errant fmt.Println 2022-06-21 11:32:07 -04:00
James Bardin
77cca0af7c remove import transformer 2022-06-20 16:11:02 -04:00
James Bardin
c002bab730 update test fixtures for better imports 2022-06-20 15:40:49 -04:00
James Bardin
e97ae28441 Combine all plan graphs, including import
Combine all plan-time graphs into a single graph builder, because
_everything is a plan_!

Convert the import graph to a plan graph. This should resolve a few edge
cases about things not being properly evaluated during import, and takes
a step towards being able to _plan_ an import.
2022-06-20 15:40:49 -04:00
Martin Atkins
fd45fb969c
Update CHANGELOG.md 2022-06-17 15:11:55 -07:00
Martin Atkins
fda0579537 Experiments supported only in alpha/dev builds
We originally introduced the idea of language experiments as a way to get
early feedback on not-yet-proven feature ideas, ideally as part of the
initial exploration of the solution space rather than only after a
solution has become relatively clear.

Unfortunately, our tradeoff of making them available in normal releases
behind an explicit opt-in in order to make it easier to participate in the
feedback process had the unintended side-effect of making it feel okay
to use experiments in production and endure the warnings they generate.
This in turn has made us reluctant to make use of the experiments feature
lest experiments become de-facto production features which we then feel
compelled to preserve even though we aren't yet ready to graduate them
to stable features.

In an attempt to tweak that compromise, here we make the availability of
experiments _at all_ a build-time flag which will not be set by default,
and therefore experiments will not be available in most release builds.

The intent (not yet implemented in this PR) is for our release process to
set this flag only when it knows it's building an alpha release or a
development snapshot not destined for release at all, which will therefore
allow us to still use the alpha releases as a vehicle for giving feedback
participants access to a feature (without needing to install a Go
toolchain) but will not encourage pretending that these features are
production-ready before they graduate from experimental.

Only language experiments have an explicit framework for dealing with them
which outlives any particular experiment, so most of the changes here are
to that generalized mechanism. However, the intent is that non-language
experiments, such as experimental CLI commands, would also in future
check Meta.AllowExperimentalFeatures and gate the use of those experiments
too, so that we can be consistent that experimental features will never
be available unless you explicitly choose to use an alpha release or
a custom build from source code.

Since there are already some experiments active at the time of this commit
which were not previously subject to this restriction, we'll pragmatically
leave those as exceptions that will remain generally available for now,
and so this new approach will apply only to new experiments started in the
future. Once those experiments have all concluded, we will be left with
no more exceptions unless we explicitly choose to make an exception for
some reason we've not imagined yet.

It's important that we be able to write tests that rely on experiments
either being available or not being available, so here we're using our
typical approach of making "package main" deal with the global setting
that applies to Terraform CLI executables while making the layers below
all support fine-grain selection of this behavior so that tests with
different needs can run concurrently without trampling on one another.

As a compromise, the integration tests in the terraform package will
run with experiments enabled _by default_ since we commonly need to
exercise experiments in those tests, but they can selectively opt-out
if they need to by overriding the loader setting back to false again.
2022-06-17 14:46:07 -07:00
Alisdair McDiarmid
479c71f93d
Merge pull request #31210 from hashicorp/update-optional-type-attributes
Edit type constraints docs for style and flow
2022-06-17 15:47:57 -04:00
Alisdair McDiarmid
0f39ead096
Merge pull request #31263 from hashicorp/alisdair/backend-remote-locks-helper-lockerror-test
states/remote: Check for LockError error type
2022-06-17 11:58:03 -04:00
Alisdair McDiarmid
31758c3661
Update CHANGELOG.md 2022-06-17 11:57:12 -04:00
Alisdair McDiarmid
c7bc82bd87
Merge pull request #31235 from hashicorp/alisdair/json-plan-unknown-outputs
json-output: Extended detail for unknown outputs
2022-06-17 11:50:21 -04:00
Alisdair McDiarmid
7fcf9734ef
Merge pull request #31236 from hashicorp/alisdair/json-plan-fix-tuple-set-unknown
json-output: Fix unknowns for tuples and sets
2022-06-17 11:48:00 -04:00
Alisdair McDiarmid
8db2552b5f
Remove experiment from optional attrs example 2022-06-17 11:38:12 -04:00
Alisdair McDiarmid
d2087fa98b states/remote: Check for LockError error type
When attempting to lock a remote state backend, failure due to an
existing lock should return an instance of LockError. This allows the
wrapping code to retry until the specified timeout, instead of
immediately exiting.

This commit adds a test for this in the TestRemoteLocks test helper,
which is used in many of the remote state backend test suites.
2022-06-17 10:51:00 -04:00
Alisdair McDiarmid
b0b69d3fad
Merge pull request #31256 from nvanheuverzwijn/vanheu/http-patch
http-backend: http backend lock error return LockError instead of generic error
2022-06-17 10:48:57 -04:00
Laura Pacilio
a864bf6b9e
Merge pull request #31105 from nvanthao/nvanthao/update-docs-implicit-provider
Add link to default provider configuration definition
2022-06-17 09:08:11 -04:00
Dirk Leser
ab93ef09ec
Readded the new example below the description 2022-06-17 14:42:52 +02:00
Dirk Leser
37d18f4229
functions/merge: Added expanation for example
Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>
2022-06-17 14:32:02 +02:00
Laura Pacilio
66f6bb50ac
Merge pull request #30275 from Mukesh05/patch-1
Update purpose.mdx
2022-06-16 13:34:46 -04:00
Nicolas Vanheuverzwijn
bb1c134b94 http-backend: http backend lock error return LockError instead of generic error 2022-06-16 11:01:01 -04:00
Martin Atkins
dc5964f8a3 refactoring: Use addrs.Map for maps with addresses as keys
We introduced the addrs.UniqueKey and addrs.UniqueKeyer mechanics as part
of implementing the ValidateMoves and ApplyMoves functions, as a way to
better encapsulate the solution to the problem that lots of our address
types aren't comparable and so cannot be used directly as map keys.

However, exposing addrs.UniqueKey handling directly in the logic adds
various noise to the algorithms and, in particular, obscures the fact that
MoveResults.Changes and MoveResult.Blocked both have different map key
types.

Here then we'll use the new addrs.Map helper type, which encapsulates the
idea of a map from an addrs.UniqueKeyer type to an arbitrary value type,
using the unique keys as the map keys internally. This does unfortunately
mean that we lose the conventional Go map access syntax and have to use
a method-based API instead, but I (subjectively) think that's an okay
compromise in return for avoiding the need to keep track inline of which
addrs.UniqueKey values correspond with which real addresses.

This is intended as an entirely-mechanical change, with equivalent
behavior to what it replaced. If anything here is doing something
materially different than what it replaced then that's a mistake.
2022-06-16 07:03:36 -07:00
Martin Atkins
eb2374070f addrs: Generic types for maps and sets of addresses
The addrs.Set type previously snuck in accidentally as part of the work
to add addrs.UniqueKey and addrs.UniqueKeyer, because without support for
generic types the addrs.Set type was a bit of a safety hazard due to not
being able to enforce particular address types at compile time.

However, with Go 1.18 adding support for type parameters we can now turn
addrs.Set into a generic type over any specific addrs.UniqueKeyer type,
and complement it with an addrs.Map type which supports addrs.UniqueKeyer
keys as a way to encapsulate the handling of maps with UniqueKey keys that
we currently do inline in various other parts of Terraform.

This doesn't yet introduce any callers of these types, but we'll convert
existing users of addrs.UniqueKeyer gradually in subsequent commits.
2022-06-16 07:03:36 -07:00
Martin Atkins
7b3e6b32d4 go.mod: Now targeting the Go 1.18 language
This means we can now use type parameter syntax where appropriate.

This commit also includes an upgrade to the golang.org/x/tools module,
in order to get a newer version of "stringer" that supports the type
parameters syntax.
2022-06-16 07:03:36 -07:00
James Bardin
0d3d95486a
Merge pull request #31218 from hashicorp/jbardin/validate-provider-local-names
Validate duplicate provider local names in `required_providers`
2022-06-15 13:51:38 -04:00
James Bardin
57c0deb01e check for duplicate defaults from resource names 2022-06-15 13:32:30 -04:00
James Bardin
9db277af42
Merge pull request #31246 from hashicorp/jbardin/copy-deps-for-comparison
copy dependency values when sorting
2022-06-14 12:44:58 -04:00
James Bardin
e7e3d80850
Merge pull request #31223 from Kagashino/fix/cos-backend-unlock-tag
Backend/COS: remove COS object lock tag either when unlock remote state
2022-06-14 12:21:01 -04:00
James Bardin
f1ce3edcc5 copy dependency values when sorting
Expanded resource instances can initially share the same dependency
slice, so we must take care to not modify the array values when
checking the dependencies.

In the future we can convert these to a generic Set data type, as we
often need to compare for equality and take the union of multiple groups
of dependencies.
2022-06-14 11:09:27 -04:00
Laura Pacilio
cbf86e0181
Merge pull request #31240 from hashicorp/add-internals-to-sidebar
Add internals to the sidebar
2022-06-14 10:55:57 -04:00
Laura Pacilio
2e4b417e3c Add internals to the sidebar 2022-06-13 17:30:11 -04:00
Craig Wright
0db75574fc
Merge pull request #31227 from pyaillet/patch-1
Fix a wrong usage of sudo in debian install doc
2022-06-13 14:04:47 -07:00
James Bardin
b6ddb087e1
Merge pull request #31237 from hashicorp/jbardin/update-go-getter
update go-getter@v1.6.2
2022-06-13 15:21:40 -04:00
James Bardin
ba5f1795ab update go-getter@v1.6.2 2022-06-13 15:04:33 -04:00
Alisdair McDiarmid
9497b2cd6f json-output: Fix unknowns for tuples and sets
The JSON output for sequences previously omitted unknown values for
tuples and sets, which made it impossible to interpret the corresponding
unknown marks. For example, consider this resource:

    resource "example_resource" "example" {
      tags = toset(["alpha", timestamp(), "charlie"])
    }

This would previously be encoded in JSON as:

    "after": {
        "tags": ["alpha", "charlie"]
    },
    "after_unknown": {
        "id": true,
        "tags": [false, true, false]
    },

That is, the timestamp value would be omitted from the output
altogether, while the corresponding unknown marks would include a value
for each of the set members.

This commit changes the behaviour to:

    "after": {
        "tags": ["alpha", null, "charlie"]
    },
    "after_unknown": {
        "id": true,
        "tags": [false, true, false]
    },

This aligns tuples and sets with the prior behaviour for lists, and
makes it clear which elements are known and which are unknown.
2022-06-13 14:33:40 -04:00
Alisdair McDiarmid
48d64eabb2 json-output: Extended detail for unknown outputs
Planned output changes are represented in the JSON output format using
the same change object as planned resource changes. This structure
includes an `after` value and a parallel `after_unknown` value, which
can be combined to determine which specific parts of a value are known
only at apply time.

Previously, structured output values would be marked in the JSON plan as
coarsely known or unknown, even if only some subset of the structure
will be known only at apply time. This simplification was unnecessary,
and this commit reuses the same logic for resource changes to give more
information to consumers of this format.

For example, consider this output:

    output "bar" {
      value = tolist([
        "hello",
        timestamp(),
        "world",
      ])
    }

The plan output for this output would be:

    + bar = [
        + "hello",
        + (known after apply),
        + "world",
      ]

For the same plan, the JSON output was previously:

    "bar": {
      "actions": [
        "create"
      ],
      "before": null,
      "after_unknown": true,
      "before_sensitive": false,
      "after_sensitive": false
    }

After this commit, the output is instead:

    "bar": {
      "actions": [
        "create"
      ],
      "before": null,
      "after": [
        "hello",
        null,
        "world"
      ],
      "after_unknown": [
        false,
        true,
        false
      ],
      "before_sensitive": false,
      "after_sensitive": false
    }
2022-06-13 14:06:03 -04:00
Alisdair McDiarmid
922de89be1 Conclude module variable optional attrs experiment 2022-06-13 12:27:21 -04:00
Laura Pacilio
f6752c6cfa
Merge pull request #31204 from parkchoongho/patch-1
Update syntax.mdx
2022-06-13 11:20:41 -04:00
Laura Pacilio
5c43afcb0e
Merge pull request #31213 from hashicorp/add-warnings-backends
Revise Backends Config Page
2022-06-13 11:05:51 -04:00
James Bardin
256b113990
Merge pull request #31176 from hashicorp/jbardin/plan-destroy-configure-provider
Configure providers during a destroy plan
2022-06-13 09:05:24 -04:00
Park Choong Ho
7510dc4d47
Update website/docs/language/resources/syntax.mdx
Co-authored-by: Laura Pacilio <83350965+laurapacilio@users.noreply.github.com>
2022-06-13 17:21:37 +09:00
Pierre-Yves Aillet
2fd3da94c7
Fix a wrong usage of sudo in debian install doc
Currently `sudo` is applied to `echo` resulting in:
`/etc/apt/sources.list.d/terraform.list: Permission denied`

Using `echo "..." | sudo tee /etc/apt/sources.list.d/terraform.list` fix the problem
2022-06-11 16:04:10 +02:00