Commit graph

12 commits

Author SHA1 Message Date
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
e79b5a1628
Replace custom testCwd function with standard testing library (#37335)
* Replace custom testCwd function with standard `testing` library

* Update comments that reference testCwd function
2025-07-16 10:41:51 +00: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
Jamie Finnigan
05b0bdac99
adopt hashicorp/cli fork of mitchellh/cli (#34429) 2023-12-20 11:04:10 +00:00
Martin Atkins
7055650270 terraform console: Option to evaluate in a planned state
Previously "terraform console" always evaluated in a kinda strange context
where resource instance data comes from the prior state, but other derived
of values end up being calculated dynamically based on the current
configuration, which is okay for simple cases but can be confusing if the
configuration has changed significantly since the most recent apply, or
if there haven't yet been any applied changes.

Now we'll allow an optional new mode where Terraform runs the normal plan
phase (as if running "terraform plan") and then uses the resulting
_planned state_ as the basis for evaluation, allowing evaluation against
a partial approximation of what the world ought to look like if these
changes were applied, without having to actually apply them first.

As with the previous use of the eval walk, it's possible that an erroneous
situation will still produce a partial evaluation scope, and so the
console still allows evaluation against that scope but with a caveat that
it might produce unexpected results. In practice this can be useful for
debugging situations like when unknown values block planning of an object,
to allow inspection of the values that are contributing to that blocked
planning operation even though the plan is not yet complete.
2023-12-01 14:35:54 -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
Brandon Croft
bd744ad4e9
Unify all sensitive value plan output as "(sensitive value)"
Previously, there was mixed usage of "(sensitive)" and "(sensitive value)" and even though it was more common to see "(sensitive)", the thought is that it's a value we are hiding rather than describing something already shown.
2022-10-24 12:50:46 -06: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/console_test.go (Browse further)