Commit graph

23 commits

Author SHA1 Message Date
Daniel Banck
4ef9684188 Rework most of the configuration loading
We previously used a loader -> BuildConfig flow to load configuration.
This commit changes most (but not all yet) flows to use the new
graph-based approach. Instead of simply recursively loading the modules,
we now need to take a stepped approach:

1. Load the root module
2. Collect the variables and their values
3. Build the configuration with the graph-based approach

Because this approach relies on different parts from different packages,
it can't easliy be done within the `configload` package. So, now we do
most of in the backend or command.
2026-03-04 11:45:59 +01:00
Radek Simko
0fe906fa8c make copyrightfix 2026-02-17 13:56:34 +00:00
Sarah French
c7da02b4a8
feat: Enable validate command to validate state_store blocks. (#38157) 2026-02-16 10:09:26 +00:00
Sarah French
694f746748
validate: Add checking the backend block to the validate command (#38021)
* feat: Make validate command detect when an unknown backend type is in use.

* feat: Make validate command detect when the backend configuration doesn't match the schema.

* fix: Stop suppressing the Required:true parts of the backend schema when validating backend blocks

* test: Add test showing validation fails when a required attribute is missing from a backend's config
2026-02-13 15:31:57 +00:00
Sarah French
940fbfb7ed
test: Add more test coverage of validate command's interaction with backend blocks (#37977)
* test: Show how the validate command doesn't detect when an unknown backend type is in the config.

* test: Minor fixes to error messages when test fails

* test: Add some TODOs in code comments

These tests are here to define existing behaviour, not define desired behaviour. I wanted to make that clear!
2025-12-17 18:09:54 +00:00
Sarah French
3eea12a1d8
test: Add test coverage for what validate command checks in resource blocks versus backend blocks. (#37972)
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
* test: Fix typo in test name

* test: Show how the validate command validates resource blocks using their schema.

* test: Show how the validate command doesn't use backends' schemas when validating backend blocks.
2025-12-05 18:13:58 +00:00
Samsondeen
2274026c68
query: add -query flag to validate command (#37671) 2025-10-01 11:33:52 +02:00
Sarah French
7199fbd2bb
Update use of testChdir to standard library's t.Chdir, remove testChdir function from codebase (#37334)
* Replace use of `testChdir` with `t.Chdir`

* Update tests to use temporary directories with copied content, instead of using directories in the repo directly.

* Remove stacks copy of testChdir function

This has been replaced with t.Chdir from the standard library

* Replace remaining simple usage of testChdir

* Update guidance for using `tempWorkingDir`

* Replace use of testChdir in a function reused in a single test

* Update comments to no longer recommend using testChdir

* Remove testChdir function!
2025-07-16 16:04:10 +01:00
Sarah French
15840b3eae
Replace use of defer with t.Cleanup in majority of command package tests, update testChdir to work with t.Cleanup (#37326)
* Replace use of `defer` with `t.Cleanup` in tests

* Fix test failures by making cleanup function permissive of the temp dir being already deleted.
2025-07-16 10:24:56 +01:00
Daniel Banck
10c9b64007
Rename schema.Block to Body (#36629) 2025-03-04 16:33:43 +01:00
Liam Cervante
14418bd198
terraform test: move override evaluation into expander (#35030)
* terraform test: move override evaluation into expander

* clarify comment
2024-04-24 07:57:29 +02:00
UKEME BASSEY
0ea25e3b40 fixing tests internal/command/init, view and argumento 2024-04-17 12:26:23 -04:00
UKEME BASSEY
370a471ecb fix json -help display and failing tests 2024-04-17 12:26:23 -04:00
Jamie Finnigan
05b0bdac99
adopt hashicorp/cli fork of mitchellh/cli (#34429) 2023-12-20 11:04:10 +00:00
Liam Cervante
57edb9c248
testing framework: add warnings for override blocks with invalid targets (#34181)
* testing framework: add warnings for override blocks with invalid targets

* pre-add the override sources for upcoming features

* address comments
2023-11-13 10:36:06 +01:00
hashicorp-copywrite[bot]
53c34ff49c
Update copyright file headers to BUSL-1.1 2023-08-10 23:43:27 +01:00
Liam Cervante
e1019b3641
testing framework: validate the configuration before terraform test (#33559)
* testing framework: call validate on the configuration before running terraform test

* address comments

* make tests pass after merge

* fix tests
2023-07-26 10:56:44 +02:00
kmoe
fbff64ad45
configs: remove import block duplicate id check (#33434) 2023-06-27 19:25:36 +01:00
CJ Horton
bd6ba6cf99
check for duplicate import blocks (#33190)
Importing to the same target address twice or importing the same ID
to multiple different resources of the same type is not allowed.
2023-05-12 23:14:44 +01:00
hashicorp-copywrite[bot]
325d18262e [COMPLIANCE] Add Copyright and License Headers 2023-05-02 15:33:06 +00:00
Eng Zer Jun
fedd315275
test: use T.TempDir to create temporary test directory (#30803)
This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.

Prior to this commit, temporary directory created using `ioutil.TempDir`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
	defer func() {
		if err := os.RemoveAll(dir); err != nil {
			t.Fatal(err)
		}
	}
is also tedious, but `t.TempDir` handles this for us nicely.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-04-08 17:34:16 +01:00
Martin Atkins
31349a9c3a Move configs/ to internal/configs/
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
Martin Atkins
ffe056bacb Move command/ to internal/command/
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
Renamed from command/validate_test.go (Browse further)