Commit graph

4023 commits

Author SHA1 Message Date
Daniel Schmidt
ba5c4ac5e3 add comment about locals using shallow validation
Some checks are pending
build / Build for windows_amd64 (push) Blocked by required conditions
build / Build for freebsd_arm (push) Blocked by required conditions
build / Build for linux_arm (push) Blocked by required conditions
build / Build for darwin_arm64 (push) Blocked by required conditions
build / Build for linux_arm64 (push) Blocked by required conditions
build / Build for windows_arm64 (push) Blocked by required conditions
build / Build Docker image for linux_386 (push) Blocked by required conditions
build / Build Docker image for linux_amd64 (push) Blocked by required conditions
build / Build Docker image for linux_arm (push) Blocked by required conditions
build / Build Docker image for linux_arm64 (push) Blocked by required conditions
build / Build e2etest for linux_386 (push) Blocked by required conditions
build / Build e2etest for windows_386 (push) Blocked by required conditions
build / Build e2etest for darwin_amd64 (push) Blocked by required conditions
build / Build e2etest for linux_amd64 (push) Blocked by required conditions
build / Build e2etest for windows_amd64 (push) Blocked by required conditions
build / Build e2etest for linux_arm (push) Blocked by required conditions
build / Build e2etest for darwin_arm64 (push) Blocked by required conditions
build / Build e2etest for linux_arm64 (push) Blocked by required conditions
build / Run e2e test for linux_386 (push) Blocked by required conditions
build / Run e2e test for windows_386 (push) Blocked by required conditions
build / Run e2e test for darwin_amd64 (push) Blocked by required conditions
build / Run e2e test for linux_amd64 (push) Blocked by required conditions
build / Run e2e test for windows_amd64 (push) Blocked by required conditions
build / Run e2e test for linux_arm (push) Blocked by required conditions
build / Run e2e test for linux_arm64 (push) Blocked by required conditions
build / Run terraform-exec test for linux amd64 (push) Blocked by required conditions
Quick Checks / Unit Tests (push) Waiting to run
Quick Checks / Race Tests (push) Waiting to run
Quick Checks / End-to-end Tests (push) Waiting to run
Quick Checks / Code Consistency Checks (push) Waiting to run
2026-02-03 17:00:05 +01:00
Daniel Schmidt
84eeb0a113 improve wording of comments 2026-02-03 17:00:05 +01:00
Daniel Schmidt
edfe22d479 match naming scheme 2026-02-03 17:00:05 +01:00
Daniel Schmidt
ae5bfbad10 fix apply time assertions for no-op resources 2026-02-03 17:00:05 +01:00
Daniel Schmidt
ce400c93df GetDeprecationMarks should return other value marks in value 2026-02-03 17:00:05 +01:00
Daniel Schmidt
9d359b02c4 add missing InConfigBody 2026-02-03 17:00:05 +01:00
Daniel Schmidt
69adc6a4c7 remove dead code 2026-02-03 17:00:05 +01:00
Daniel Schmidt
9cf9235582 track down precise deprecation locations in complex output values 2026-02-03 17:00:05 +01:00
Daniel Schmidt
9a1e117ea9 pull range finding for expressions into separate method 2026-02-03 17:00:05 +01:00
Daniel Schmidt
425263040f only unmark deep when necessary 2026-02-03 17:00:05 +01:00
Daniel Schmidt
5ed7d5134e refactor deprecation diag creation 2026-02-03 17:00:05 +01:00
Daniel Schmidt
3fd7a5052f limit the amount of additional remove deprecation mark calls 2026-02-03 17:00:05 +01:00
Daniel Schmidt
11e49b983a only unmark deep once for Validate 2026-02-03 17:00:05 +01:00
Daniel Schmidt
c7bc22ed79 only unmark deep once for ValidateDeep 2026-02-03 17:00:05 +01:00
Daniel Schmidt
76747e174c use format.CtyPath for formatting go-cty paths 2026-02-03 16:47:54 +01:00
Daniel Schmidt
7b28c88e66 improve wording of deprecation marks 2026-02-03 16:47:54 +01:00
Daniel Schmidt
3bafac0d56 we can't savely detect deprecations within provisioners during plan 2026-02-03 16:47:54 +01:00
Daniel Schmidt
7eaf6daf60 add deprecation marks to resources based on schema 2026-02-03 16:47:54 +01:00
Sarah French
02a4ddce1b
fix: Fail an apply command if the plan file was generated for a workspace that isn't the selected workspace (#37955)
* fix: Fail apply command if the plan file was generated for a workspace that isn't the selected workspace.

* Add change file

* test: Update test helper to include Workspace name in plan representation

* fix: Make error message more generic, so is applicable to backend and cloud blocks.

* fix: Make error message specific to backend or cloud block

* test: Add separate tests for backend/cloud usage

* test: Update remaining tests to include a value for Workspace in mocked plans

* Apply suggestions from code review

Co-authored-by: Radek Simko <radeksimko@users.noreply.github.com>

* fix: Panic when a plan file has missing workspace data

* test: Update test to match changes in error text

---------

Co-authored-by: Radek Simko <radeksimko@users.noreply.github.com>
2026-02-03 15:29:58 +00:00
Daniel Schmidt
379fa79c3e ElaborateFromConfigBody handles deeply nested paths more precisely 2026-02-03 16:04:43 +01:00
Daniel Schmidt
5723a7a26b refactor into switch statement 2026-02-03 16:04:43 +01:00
Daniel Schmidt
b09ef138fc use validate for primitive types 2026-02-03 16:04:43 +01:00
Daniel Schmidt
e6d969a2eb we only want to send diagnostics for deeply nested deprecations in certain locations
Mainly terminal locations for the value where they are used, such as the config of a resource, for_each, outputs.
We don't want to evaluate the deprecation deeply when it comes to values where the value is not yet used, e.g. locals
This is because if e.g. a deeply nested value is deprecated it should still be ok for the entire object to be in a local
whereas the same object should give a warning in e.g. an output
2026-02-03 16:04:43 +01:00
Daniel Schmidt
2f392d904e deprecation.Validate should only check top-level marks 2026-02-03 16:04:43 +01:00
Daniel Schmidt
75445e1ef8 use a string as deprecation origin to help with indirect references
We want to be able to give better information if e.g. the entire module is stored in a local and the deprecated value is only later used.

Where the diag is emitted we might only see the local and not the true origin of the deprecation

A string identifying the source of the deprecation should help
2026-02-03 16:04:43 +01:00
Daniel Schmidt
c9cc64a260 move stray check for deprecation to central location 2026-02-03 16:04:43 +01:00
Daniel Schmidt
844bcd8e2c contextualFromConfigBody should also apply for overridden diagnostics 2026-02-03 16:04:43 +01:00
Daniel Schmidt
a96df66a9a display origin of deprecated value in diagnostic 2026-02-03 16:04:43 +01:00
Daniel Schmidt
3a36e7732b refactor: extract write snippet in diagnostic rendering 2026-02-03 16:04:43 +01:00
Daniel Schmidt
ea7f1e3043 add extra origin information for deprecation diagnostics 2026-02-03 16:04:43 +01:00
Daniel Schmidt
c02223e94c use value without deprecations after validating 2026-02-03 15:57:28 +01:00
Daniel Schmidt
5ee1bece21 detect deprecation marks in more places 2026-02-03 15:57:28 +01:00
Daniel Schmidt
0a9bfcc8d0 move test case to more appropriate PR
https://github.com/hashicorp/terraform/pull/38006 is dealing with resource deprecation
2026-02-03 15:57:28 +01:00
Daniel Schmidt
5b40f274b2 use EvalContext.Path to get module path for deprecation surpression
I decided against it before since a lot of tests were panicing, but after consulting with peers I found out the tests were just minimally set up and before it was just fine without the current scope being set. Now we require it to be set as it would in a normal execution therefore I had to add a bit of setup to the tests
2026-02-03 15:57:28 +01:00
Daniel Schmidt
958a1ae1e7 variable and output deprecation
Variables can be deprecated through the `deprecated` attribute. If set the variable
will emit a diagnostic if a values is passed to it. This entails both root level and
module variables.

Outputs can be deprecated through the `deprecated` attribute as well. If set wherever
the value is used a diagnostic will be emitted. Root level outputs can not be deprecated.
The only acceptable usage of a deprecated output is another deprecated output (forwarding
the deprecation to the module user).

If modules not under your control have deprecation warnings you can add a `suppress_deprecations_warnigns`
attribute to the module call in question to silence any deeply nested warnings.
2026-02-03 15:57:28 +01:00
Daniel Schmidt
13247d19e2 add deprecation singleton
This struct tracks and validates deprecations in the context of a
graph walk. We need a struct to keep track of the module calls that
opt-out of deprecation warnings.
2026-02-03 15:39:25 +01:00
Kristin Laemmert
7e37e518c4 actions test refactor 2026-02-03 08:22:19 -05:00
Radek Simko
41102accc6
command: Fix copy-paste error in error message (#38116) 2026-02-03 13:06:13 +00:00
Radek Simko
1fde2537c2
command/init: Avoid ignoring errors when setting PSS configs (#38115) 2026-02-03 13:05:52 +00:00
Sarah French
2465e326a2
refactor: Use existing methods to detect if a provider is built in (#38118) 2026-02-03 12:52:26 +00:00
Daniel Schmidt
93a38f893b remove deprecation origin for now
we will add sth like this again when we will be able display a nicer diagnostic with the origin
2026-02-03 13:32:06 +01:00
Daniel Schmidt
d813ad14f7 add deprecation marks 2026-02-03 13:32:06 +01:00
Daniel Schmidt
c3cc222a1f separate tests between different modes
Some checks failed
build / Build for freebsd_amd64 (push) Has been cancelled
build / Build for linux_amd64 (push) Has been cancelled
build / Build for openbsd_amd64 (push) Has been cancelled
build / Build for solaris_amd64 (push) Has been cancelled
build / Build for windows_amd64 (push) Has been cancelled
build / Build for freebsd_arm (push) Has been cancelled
build / Build for linux_arm (push) Has been cancelled
build / Build for darwin_arm64 (push) Has been cancelled
build / Build for linux_arm64 (push) Has been cancelled
build / Build for windows_arm64 (push) Has been cancelled
build / Build Docker image for linux_386 (push) Has been cancelled
build / Build Docker image for linux_amd64 (push) Has been cancelled
build / Build Docker image for linux_arm (push) Has been cancelled
build / Build Docker image for linux_arm64 (push) Has been cancelled
build / Build e2etest for linux_386 (push) Has been cancelled
build / Build e2etest for windows_386 (push) Has been cancelled
build / Build e2etest for darwin_amd64 (push) Has been cancelled
build / Build e2etest for linux_amd64 (push) Has been cancelled
build / Build e2etest for windows_amd64 (push) Has been cancelled
build / Build e2etest for linux_arm (push) Has been cancelled
build / Build e2etest for darwin_arm64 (push) Has been cancelled
build / Build e2etest for linux_arm64 (push) Has been cancelled
build / Run e2e test for linux_386 (push) Has been cancelled
build / Run e2e test for windows_386 (push) Has been cancelled
build / Run e2e test for darwin_amd64 (push) Has been cancelled
build / Run e2e test for linux_amd64 (push) Has been cancelled
build / Run e2e test for windows_amd64 (push) Has been cancelled
build / Run e2e test for linux_arm (push) Has been cancelled
build / Run e2e test for linux_arm64 (push) Has been cancelled
build / Run terraform-exec test for linux amd64 (push) Has been cancelled
2026-01-30 16:13:59 +01:00
Daniel Schmidt
7307d92619 ignore sorting of diagnostics
The events are non-deterministic
2026-01-30 16:13:59 +01:00
Daniel Schmidt
fa14a97346 stacks: ensure an empty plan sends an applied status for the component 2026-01-30 16:13:59 +01:00
Daniel Schmidt
ed79a4745b stacks: add apply time progress message test case 2026-01-30 16:13:59 +01:00
Daniel Schmidt
c24699eab7 stacks: ensure an empty plan produces a planned status 2026-01-30 16:13:59 +01:00
Daniel Schmidt
dce80d4465 stacks: add tests to validate progress events for destroy plans 2026-01-30 16:13:59 +01:00
Daniel Schmidt
70bed8017b add error-case pre and post diff hook 2026-01-30 16:13:59 +01:00
Daniel Schmidt
4b34066cf2 add error to Pre and PostDiff hook
We need this information for stacks to forward the error to the progress
stream as stacks expects everything that reports itself starting to e.g. plan
to also finish either in an error or with success.
2026-01-30 16:13:59 +01:00