Commit graph

22 commits

Author SHA1 Message Date
Radek Simko
0fe906fa8c make copyrightfix 2026-02-17 13:56:34 +00:00
Daniel Schmidt
c20bf67020 remove language experiment, this is guarded by being in an alpha release 2025-07-18 13:07:43 +02:00
Kristin Laemmert
386988cb50
Decode action blocks and action_triggers inside resource blocks. (#37030)
* Decode action blocks and action_triggers inside resource blocks.

This commit adds decoding of action and action_triggers inside terraform configuration. I added an Actions experiment as a hacky way of keeping the functionality out of main until we're ready for the alpha; this may never be an experiment but it's a handy feature flag so we don't have to do all the work in a long-lived feature branch.

* remove legacy shim handling
* validate that the referenced entry in actions is indeed an action
2025-05-14 09:07:27 -04:00
kmoe
fab3673f8d
lang: stabilise ephemeral values experiment (#35636)
* lang: stabilise ephemeral values experiment

Stabilise the ephemeral values experiment and ephemeralasnull
experimental function.

* simplify handling of apply time input vars

As the final step in stabilising the ephemeral values experiment, we can
remove the separate code path for handling input variables supplied via
-var and -var-file during apply.

The intent here is conveyed in the tests: when applying a saved plan,
all ephemeral variables set in the plan (the "apply-time
variables"), must be set, and no others.

As per the TODO copied from the prototype, there is some more work to be
done here in making the handling of undeclared variables during apply as
sophisticated as that during plan, emitting helpful warnings (for
example) when input variables are supplied unnecessarily via environment
variables.

* experiments: officially conclude EV experiment

---------

Co-authored-by: Radek Simko <radek.simko@gmail.com>
2024-08-26 11:43:16 +01:00
Martin Atkins
1ef2ad7d4c experiments: "ephemeral_values" language experiment
This doesn't actually do anything yet, but in future commits it will
enable some new language features for marking input variables and output
values as "ephemeral", meaning that they don't get saved as part of
state snapshots or saved plan files.
2024-06-05 09:09:30 -07:00
kmoe
1e2d4a2ecc
lang: stabilise templatestring func experiment (#35224)
* lang: stabilise templatestring func experiment

* command/jsonfunction: marshal templatestring

* docs: add templatestring
2024-05-28 16:50:25 +01:00
Martin Atkins
3b620bfe69 terraform: Stabilize the variable_validation_crossref experiment
Previously we introduced a language experiment that would permit variable
validation rules to refer to other objects declared in the same module
as the variable.

Now that experiment is concluded and its behavior is available for all
modules.

This final version deviates slightly from the experiment: we learned from
the experimental implementation that we accidentally made the "validate"
command able to validate constant-valued input variables in child modules
despite the usual rule that input variables are unknown during validation,
because the previous compromise bypassed the main expression evaluator
and built its own evaluation context directly.

Even though that behavior was not intended, it's a useful behavior that is
protected by our compatibility promises and so this commit includes a
slightly hacky emulation of that behavior, in eval_variable.go, that
fetches the variable value in the same way the old implementation would
have and then modifies the hcl evaluation context to include that value,
while preserving anything else that our standard evaluation context
builder put in there. That narrowly preserves the old behavior for
expressions that compare the variable value directly to a constant, while
treating all other references (which were previously totally invalid) in
the standard way. This quirk was already covered by the existing test
TestContext2Validate_variableCustomValidationsFail, which fails if the
special workaround is removed.
2024-05-22 08:14:45 -07:00
Martin Atkins
847925b531 experiments: template_string_func experiment keyword
This doesn't actually do anything yet, but we'll make it do something in
a future commit.
2024-04-29 09:20:53 -07:00
Martin Atkins
ea67f2093f experiments: variable_validation_crossref is a current experiment
As of this commit this experiment doesn't actually change any behavior at
all; as usual, those changes will follow in subsequent commits.
2024-04-05 14:01:48 -07:00
Nick Fagerlund
d5be799cb9 End unknown_instances language experiment, in favor of whole-plan option
We're still iterating on the ability to defer unplannable changes to a later
plan. However, instead of enabling it via a "contagious" experimental feature
switch that can bubble up from any module, it's now behind a per-plan option in
the PlanOpts struct.

That option travels a winding path into the internals (see previous commit), and
node execution logic can then access it during the plan walk via the
`Deferred.DeferralAllowed()` method. This commit updates the spot where we
switch between the deferral yea/nay code paths to respect this top-level plan
option rather than the experiment flag.
2024-04-02 17:42:52 -07:00
Martin Atkins
78e2e20157 experiments: "unknown_instances" is a current experiment
This doesn't do anything yet as of this commit, but in future commits it
will gate the possibility for count and for_each arguments to have unknown
values, which will then cause affected objects to have their planning
deferred to a future run.
2024-01-24 15:27:52 -08:00
hashicorp-copywrite[bot]
53c34ff49c
Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
hashicorp-copywrite[bot]
325d18262e [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
Martin Atkins
783a07d9e8 build: Use Go 1.19
Go 1.19's "fmt" has some awareness of the new doc comment formatting
conventions and adjusts the presentation of the source comments to make
it clearer how godoc would interpret them. Therefore this commit includes
various updates made by "go fmt" to acheve that.

In line with our usual convention that we make stylistic/grammar/spelling
tweaks typically only when we're "in the area" changing something else
anyway, I also took this opportunity to review most of the comments that
this updated to see if there were any other opportunities to improve them.
2022-08-22 10:59:12 -07:00
Martin Atkins
b88e29e473 configs: Show tailored message for optional attrs experiment
Since we've both concluded the module_variables_optional_attrs experiment
and made experiments available only in alpha releases in the same minor
release, we accidentally made the more general message about experiments
not being available mask the specific message about the experiment being
concluded.

In order to give better feedback to those who were participating in the
experiment in earlier Terraform releases, we'll retain a minimal exception
to our checks to allow the "experiment has concluded" error message to
shine through if and only if that is the only selected experiment.
2022-07-01 09:08:12 -07:00
Alisdair McDiarmid
922de89be1 Conclude module variable optional attrs experiment 2022-06-13 12:27:21 -04:00
Alisdair McDiarmid
bb35f02c95 Conclude preconditions/postconditions experiment 2022-04-04 15:54:40 -04:00
Martin Atkins
82c518209d experiments: New "preconditions_postconditions" experiment 2022-01-28 11:00:29 -05:00
Martin Atkins
94cbc8fb5d experiments: config_driven_move has concluded
Based on feedback during earlier alpha releases, we've decided to move
forward with the current design for the first phase of config-driven
refactoring.

Therefore here we've marked the experiment as concluded with no changes
to the most recent incarnation of the functionality. The other changes
here are all just updating test fixtures to no longer declare that they
are using experimental features.
2021-11-01 08:46:15 -07:00
Martin Atkins
6b8e103d6a configs: Include "moved" blocks when merging multiple files into a module
An earlier commit added logic to decode "moved" blocks and do static
validation of them. Here we now include that result also in modules
produced from those files, which we can then use in Terraform Core to
actually implement the moves.

This also places the feature behind an active experiment keyword called
config_driven_move. For now activating this doesn't actually achieve
anything except let you include moved blocks that Terraform will summarily
ignore, but we'll expand the scope of this in later commits to eventually
reach the point where it's really usable.
2021-07-01 08:28:02 -07:00
Kristin Laemmert
3acb5e2841
configs: add decodeMovedBlock behind a locked gate. (#28973)
This PR adds decoding for the upcoming "moved" blocks in configuration. This code is gated behind an experiment called EverythingIsAPlan, but the experiment is not registered as an active experiment, so it will never run (there is a test in place which will fail if the experiment is ever registered).

This also adds a new function to the Targetable interface, AddrType, to simplifying comparing two addrs.Targetable.

There is some validation missing still: this does not (yet) descend into resources to see if the actual resource types are the same (I've put this off in part because we will eventually need the provider schema to verify aliased resources, so I suspect this validation will have to happen later on).
2021-06-21 10:53:16 -04:00
Martin Atkins
26e5320a78 Move experiments/ to internal/experiments/
This is part of a general effort to move all of Terraform's non-library
package surface under internal in order to reinforce that these are for
internal use within Terraform only.

If you were previously importing packages under this prefix into an
external codebase, you could pin to an earlier release tag as an interim
solution until you've make a plan to achieve the same functionality some
other way.
2021-05-17 14:09:07 -07:00